- 修复 聚合根仓储级联插入 OnToMany 雪花主键只插入一条记录;

This commit is contained in:
2881099
2024-05-17 15:25:27 +08:00
parent d568417924
commit 885826254a
2 changed files with 114 additions and 125 deletions

View File

@ -146,6 +146,7 @@ namespace FreeSql
//}
return;
}
var table = fsql.CodeFirst.GetTableByEntity(elementType);
Dictionary<string, object> dictBefore = new Dictionary<string, object>();
Dictionary<string, object> dictAfter = new Dictionary<string, object>();
foreach (var item in collectionBefore)
@ -158,8 +159,11 @@ namespace FreeSql
var key = fsql.GetEntityKeyString(elementType, item, false);
if (!string.IsNullOrEmpty(key))
{
if (dictAfter.ContainsKey(key) == false)
if (dictAfter.ContainsKey(key) == false)
dictAfter.Add(key, item);
else if (key == "0" && table.Primarys.Length == 1 &&
new[] { typeof(long), typeof(long) }.Contains(table.Primarys[0].CsType))
tracking.InsertLog.Add(NativeTuple.Create(elementType, item));
}
else tracking.InsertLog.Add(NativeTuple.Create(elementType, item));
}