- 修复 FreeSql.DbContext 对同一实体重复 Update,第二次无效的 Bug;

This commit is contained in:
28810 2020-09-14 11:33:20 +08:00
parent ad12402926
commit 704e59bf21
4 changed files with 31 additions and 19 deletions

View File

@ -408,7 +408,18 @@ namespace FreeSql
foreach (var item in data)
{
if (_dicUpdateTimes.ContainsKey(item))
{
var itemCopy = CreateEntityState(item).Value;
await DbContextFlushCommandAsync();
if (_table.VersionColumn != null)
{
var itemVersion = _db.OrmOriginal.GetEntityValueWithPropertyName(_entityType, item, _table.VersionColumn.CsName);
_db.OrmOriginal.MapEntityValue(_entityType, itemCopy, item);
_db.OrmOriginal.SetEntityValueWithPropertyName(_entityType, item, _table.VersionColumn.CsName, itemVersion);
}
else
_db.OrmOriginal.MapEntityValue(_entityType, itemCopy, item);
}
_dicUpdateTimes.Add(item, 1);
var state = CreateEntityState(item);

View File

@ -451,7 +451,18 @@ namespace FreeSql
foreach (var item in data)
{
if (_dicUpdateTimes.ContainsKey(item))
{
var itemCopy = CreateEntityState(item).Value;
DbContextFlushCommand();
if (_table.VersionColumn != null)
{
var itemVersion = _db.OrmOriginal.GetEntityValueWithPropertyName(_entityType, item, _table.VersionColumn.CsName);
_db.OrmOriginal.MapEntityValue(_entityType, itemCopy, item);
_db.OrmOriginal.SetEntityValueWithPropertyName(_entityType, item, _table.VersionColumn.CsName, itemVersion);
}
else
_db.OrmOriginal.MapEntityValue(_entityType, itemCopy, item);
}
_dicUpdateTimes.Add(item, 1);
var state = CreateEntityState(item);

View File

@ -329,7 +329,10 @@
</member>
<member name="M:FreeSql.IBaseRepository`1.BeginEdit(System.Collections.Generic.List{`0})">
<summary>
€蟋狗シ冶セ第焚謐ョ<E8AC90>檎┯蜷手ー<E6898B>畑譁ケ豕<EFBDB9> EndEdit 蛻<>梵蜃コ豺サ蜉<EFBDBB>縲譁ケ豕募宵謾ッ謖∝黒陦ィ謫堺ス懶シ御ク肴髪謖∝ッシ闊ェ螻樊€ァ郤ァ閨比ソ晏ュ<E6998F>
开始编辑数据,然后调用方法 EndEdit 分析出添加、修改、删除 SQL 语句进行执行<para></para>
场景winform 加载表数据后,一顿添加、修改、删除操作之后,最后才点击【保存】<para></para><para></para>
示例https://github.com/dotnetcore/FreeSql/issues/397<para></para>
注意:* 本方法只支持单表操作,不支持导航属性级联保存
</summary>
<param name="data"></param>
</member>
@ -531,21 +534,3 @@
</member>
</members>
</doc>
me="M:FreeSqlDbContextExtensions.CreateUnitOfWork(IFreeSql)">
<summary>
蛻帛サコ蝓コ莠惹サ灘お蜉溯<E89C89><EFBFBD>キ・菴懷黒蜈<E9BB92>シ悟苅蠢<E88B85>スソ逕ィ using 蛹<>性菴ソ逕ィ
</summary>
<param name="that"></param>
<returns></returns>
</member>
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
<summary>
謇ケ驥乗ウィ蜈・ Repository<72>悟庄莉・蜿り€<E3828A>サ」遐∬<E98190>陦瑚ー<E7919A>
</summary>
<param name="services"></param>
<param name="globalDataFilter"></param>
<param name="assemblies"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@ -36,6 +36,11 @@ namespace FreeSql.Tests.Firebird
public void ExistsTable()
{
var fsql = g.firebird;
try
{
fsql.Ado.ExecuteNonQuery("drop table test_existstb011");
}
catch { }
Assert.False(fsql.DbFirst.ExistsTable("test_existstb011"));
Assert.False(fsql.DbFirst.ExistsTable("test_existstb011", false));
fsql.CodeFirst.SyncStructure(typeof(test_existstb011));