- 修复 聚合根仓储 InsertOrUpdate 非自增无法插入的 bug;

This commit is contained in:
2881099 2022-11-09 21:23:36 +08:00
parent 904e2513a6
commit 6d2b87449d
3 changed files with 3 additions and 9 deletions

View File

@ -168,12 +168,9 @@ namespace FreeSql
return entity;
}
if (table.Primarys.Where(a => a.Attribute.IsIdentity).Count() == table.Primarys.Length)
{
Orm.ClearEntityPrimaryValueWithIdentity(EntityType, entity);
return await InsertAsync(entity, cancellationToken);
}
throw new Exception(DbContextStrings.CannotAdd_PrimaryKey_NotSet(Orm.GetEntityString(EntityType, entity)));
}
public virtual Task<int> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default) => UpdateAsync(new[] { entity }, cancellationToken);
async public virtual Task<int> UpdateAsync(IEnumerable<TEntity> entitys, CancellationToken cancellationToken = default)

View File

@ -221,12 +221,9 @@ namespace FreeSql
return entity;
}
if (table.Primarys.Where(a => a.Attribute.IsIdentity).Count() == table.Primarys.Length)
{
Orm.ClearEntityPrimaryValueWithIdentity(EntityType, entity);
return Insert(entity);
}
throw new Exception(DbContextStrings.CannotAdd_PrimaryKey_NotSet(Orm.GetEntityString(EntityType, entity)));
}
public virtual int Update(TEntity entity) => Update(new[] { entity });
public virtual int Update(IEnumerable<TEntity> entitys)

View File

@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>1.0.3</Version>
<Version>1.0.5</Version>
</PropertyGroup>
<ItemGroup>