update

28810
2019-03-29 21:21:08 +08:00
parent b59436f2b0
commit bb41acc9d6
2 changed files with 18 additions and 0 deletions

@@ -115,6 +115,16 @@ var t10 = update.SetRaw("Title = {0}", "新标题").Where("Id = {0}", 1).ToSql()
在使用 IgnoreColumns 的情况下,只有未被指定的列会保存;
## 行级锁(乐观锁)
更新整个实体数据时,在并发情况下极容易造成旧数据将新的记录更新。
行级锁的原理是利用实体某字段long version更新前先查询数据此时 version 为 1更新时产生的 SQL 会附加 where version = 1当修改失败时即 Affrows == 0抛出异常。
每个实体只支持一个行级锁属性,在属性前标记特性:[Column(IsVersion = true)] 即可。
> 适用 SetSource 更新,每次更新 version 的值都会增加 1
## 参考资料
- [《数据库事务》](https://github.com/2881099/FreeSql/wiki/%e4%ba%8b%e5%8a%a1)

@@ -1,6 +1,14 @@
完整版本:年数-月-日-当日版本号FreeSql、FreeSql.Repository、FreeSql.DbContext 版本号相同。
## v0.3.27
- 增加 行级锁功能,适用修改实体,[参考资料](https://github.com/2881099/FreeSql/wiki/%e4%bf%ae%e6%94%b9)
- 增加 FreeSql.Repository 默认依赖注入的方式,同时保留原有 Autofac
- 优化 FreeSql.Repository Insert 逻辑,参考了 FreeSql.DbContext
- 优化 FreeSql.IUpdate 参照 IInsert 对大批量更新,拆分执行;
- 修复 FreeSql.IInsert ClearData 重复利用的 bug使用 IgnoreColumns 进行大批量插入时会发生);
## v0.3.26
- 修复 SqlServer CodeFirst 迁移多主键的 bug [#23](https://github.com/2881099/FreeSql/issues/23)