修改仓储

Uat_Study
hang 2022-04-26 09:43:57 +08:00
parent 9f1df7aa70
commit dee2ee388d
1 changed files with 18 additions and 16 deletions

View File

@ -224,22 +224,6 @@ namespace IRaCIS.Core.Infra.EFCore
} }
/// <summary>EF跟踪方式 外层先有查询好的完成实体,再更新部分字段 稽查的时候需要完整的实体信息</summary>
public async Task<bool> PartialUpdateAsync(TEntity waitModifyEntity, Expression<Func<TEntity, TEntity>> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default)
{
var entityEntry = _dbContext.Entry(waitModifyEntity);
entityEntry.State = EntityState.Detached;
ModifyPartialFiled(waitModifyEntity, updateFactory);
return await SaveChangesAsync(autoSave);
}
public async Task QueryThenPartiallyUpdateAsync(Expression<Func<TEntity, bool>> updateFilter, public async Task QueryThenPartiallyUpdateAsync(Expression<Func<TEntity, bool>> updateFilter,
Expression<Func<TEntity, TEntity>> updateFactory, Expression<Func<TEntity, TEntity>> updateFactory,
bool autoSave = false, CancellationToken cancellationToken = default) bool autoSave = false, CancellationToken cancellationToken = default)
@ -259,6 +243,22 @@ namespace IRaCIS.Core.Infra.EFCore
} }
/// <summary>EF跟踪方式 外层先有查询好的完成实体,再更新部分字段 稽查的时候需要完整的实体信息</summary>
public async Task<bool> PartialUpdateAsync(TEntity waitModifyEntity, Expression<Func<TEntity, TEntity>> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default)
{
var entityEntry = _dbContext.Entry(waitModifyEntity);
entityEntry.State = EntityState.Detached;
ModifyPartialFiled(waitModifyEntity, updateFactory);
return await SaveChangesAsync(autoSave);
}
/// <summary>EF跟踪方式 先查询出来,再更新部分字段 稽查的时候需要完整的实体信息</summary> /// <summary>EF跟踪方式 先查询出来,再更新部分字段 稽查的时候需要完整的实体信息</summary>
public async Task<TEntity> QueryThenPartiallyUpdateAsync(Guid id, Expression<Func<TEntity, TEntity>> updateFactory, public async Task<TEntity> QueryThenPartiallyUpdateAsync(Guid id, Expression<Func<TEntity, TEntity>> updateFactory,
bool autoSave = false, CancellationToken cancellationToken = default) bool autoSave = false, CancellationToken cancellationToken = default)
@ -298,6 +298,8 @@ namespace IRaCIS.Core.Infra.EFCore
_dbContext.Entry(waitModifyEntity).Property(prop.Name).IsModified = true; _dbContext.Entry(waitModifyEntity).Property(prop.Name).IsModified = true;
} }
} }