- 修复 聚合根仓储 InsertOrUpdate OneToMany 只插入一条记录的 bug;

This commit is contained in:
2881099
2024-02-27 19:35:48 +08:00
parent b18f9a5264
commit c5b1488831
8 changed files with 779 additions and 308 deletions

View File

@ -53,7 +53,7 @@ namespace FreeSql
bool LocalCanInsert(Type entityType, object entity, bool isadd)
{
var stateKey = rootRepository.Orm.GetEntityKeyString(entityType, entity, false);
if (stateKey == null) return true;
if (string.IsNullOrEmpty(stateKey)) return true;
if (ignores.TryGetValue(entityType, out var stateKeys) == false)
{
if (isadd)

View File

@ -106,7 +106,7 @@ namespace FreeSql
bool LocalCanInsert(Type entityType, object entity, bool isadd)
{
var stateKey = rootRepository.Orm.GetEntityKeyString(entityType, entity, false);
if (stateKey == null) return true;
if (string.IsNullOrEmpty(stateKey)) return true;
if (ignores.TryGetValue(entityType, out var stateKeys) == false)
{
if (isadd)

View File

@ -151,12 +151,12 @@ namespace FreeSql
foreach (var item in collectionBefore)
{
var key = fsql.GetEntityKeyString(elementType, item, false);
if (key != null) dictBefore.Add(key, item);
if (!string.IsNullOrEmpty(key)) dictBefore.Add(key, item);
}
foreach (var item in collectionAfter)
{
var key = fsql.GetEntityKeyString(elementType, item, false);
if (key != null)
if (!string.IsNullOrEmpty(key))
{
if (dictAfter.ContainsKey(key) == false)
dictAfter.Add(key, item);