Skip to content

Commit 8858262

Browse files
committed
- 修复 聚合根仓储级联插入 OnToMany 雪花主键只插入一条记录;
1 parent d568417 commit 8858262

File tree

2 files changed

+114
-125
lines changed

2 files changed

+114
-125
lines changed

Extensions/FreeSql.Extensions.AggregateRoot/AggregateRootRepository/AggregateRootUtils.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ void LocalCompareEntityValueCollection(Type elementType, IEnumerable collectionB
146146
//}
147147
return;
148148
}
149+
var table = fsql.CodeFirst.GetTableByEntity(elementType);
149150
Dictionary<string, object> dictBefore = new Dictionary<string, object>();
150151
Dictionary<string, object> dictAfter = new Dictionary<string, object>();
151152
foreach (var item in collectionBefore)
@@ -158,8 +159,11 @@ void LocalCompareEntityValueCollection(Type elementType, IEnumerable collectionB
158159
var key = fsql.GetEntityKeyString(elementType, item, false);
159160
if (!string.IsNullOrEmpty(key))
160161
{
161-
if (dictAfter.ContainsKey(key) == false)
162+
if (dictAfter.ContainsKey(key) == false)
162163
dictAfter.Add(key, item);
164+
else if (key == "0" && table.Primarys.Length == 1 &&
165+
new[] { typeof(long), typeof(long) }.Contains(table.Primarys[0].CsType))
166+
tracking.InsertLog.Add(NativeTuple.Create(elementType, item));
163167
}
164168
else tracking.InsertLog.Add(NativeTuple.Create(elementType, item));
165169
}

FreeSql/FreeSql.xml

Lines changed: 109 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)