From 33e2e12a8e5ee589a73a5a140d3904008dd31437 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Fri, 3 Apr 2020 09:26:54 +0800 Subject: [PATCH] update --- CodeFirst.md | 17 ----------------- 事务.md | 7 +++++++ 更新日志.md | 4 +++- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/CodeFirst.md b/CodeFirst.md index f1d45e0..f7af36c 100644 --- a/CodeFirst.md +++ b/CodeFirst.md @@ -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 单例模式 ``` diff --git a/事务.md b/事务.md index 26f2545..5f25d06 100644 --- a/事务.md +++ b/事务.md @@ -1,3 +1,10 @@ +事务的几种用法: + +- 第一种 外部事务,由外部控制事务提交回滚,需要层层传递; +- 第二种 同线程事务,由 fsql.Transaction 管理事务提交回滚,不需要层层传递事务对象(缺点:不支持异步); +- 第三种 UnitOfWork 事务,最好配合 Ioc 使用; +- 第四种 DbContext,其实也是 UnitOfWork,只不过 UnitOfWork 和 DbContext 绑定在一起; + ## 1、外部事务 在外部开启事务的场景,可使用 WithTransaction 传入事务对象。 diff --git a/更新日志.md b/更新日志.md index 1ef6f6f..023738d 100644 --- a/更新日志.md +++ b/更新日志.md @@ -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