update

28810
2020-04-03 09:26:54 +08:00
parent ec5d1936bf
commit 33e2e12a8e
3 changed files with 10 additions and 18 deletions

@@ -8,24 +8,7 @@ FreeSql 支持 CodeFirst 迁移结构至数据库,这应该是(O/RM)必须标
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
.UseAutoSyncStructure(true) //自动同步实体结构【开发环境必备】
.UseMonitorCommand(cmd => Console.Write(cmd.CommandText))
.UseSeedData(sd => sd //CodeFirst 种子数据
.Apply(new[]
{
new Products { Id = 1, title = "product-1" },
new Products { Id = 2, title = "product-2" },
new Products { Id = 3, title = "product-3" },
new Products { Id = 4, title = "product-4" }
})
.Apply(new[]
{
new S_SysConfig { Name = "testkey11", clicks = 11, title = "testtitle11" },
new S_SysConfig { Name = "testkey22", clicks = 22, title = "testtitle22" },
new S_SysConfig { Name = "testkey33", clicks = 33, title = "testtitle33" }
})
)
.Build(); //请务必定义成 Singleton 单例模式
```

@@ -1,3 +1,10 @@
事务的几种用法:
- 第一种 外部事务,由外部控制事务提交回滚,需要层层传递;
- 第二种 同线程事务,由 fsql.Transaction 管理事务提交回滚,不需要层层传递事务对象(缺点:不支持异步);
- 第三种 UnitOfWork 事务,最好配合 Ioc 使用;
- 第四种 DbContext其实也是 UnitOfWork只不过 UnitOfWork 和 DbContext 绑定在一起;
## 1、外部事务
在外部开启事务的场景,可使用 WithTransaction 传入事务对象。

@@ -4,7 +4,9 @@
## v1.4.0-preview
- 修复 PostgreSQL CodeFirst/DbFirst 系统表的版本兼容问题;
- 增加 FreeSqlBuilder UseSeedData 设定 CodeFirst 种子数据;
- 增加 EfCoreFluentApi HasData 设定 CodeFirst 种子数据;
- 完善 EfCoreFluentApi 功能测试;
- 增加 DbContextOptions.NoneParameter 设置是否使用参数化执行 Insert/Update
## v1.3.4