Skip to content

Commit

Permalink
- 修复 聚合根仓储级联插入 OnToMany 雪花主键只插入一条记录;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed May 17, 2024
1 parent d568417 commit 8858262
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void LocalCompareEntityValueCollection(Type elementType, IEnumerable collectionB
//}
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)
Expand All @@ -158,8 +159,11 @@ void LocalCompareEntityValueCollection(Type elementType, IEnumerable collectionB
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));
}
Expand Down
233 changes: 109 additions & 124 deletions FreeSql/FreeSql.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8858262

Please sign in to comment.