From dee2ee388dcd8450610d7b8e92eebc33984abc9c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 26 Apr 2022 09:43:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=93=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/Repository.cs | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index 26e5dfc0..4b4a3bd6 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -224,22 +224,6 @@ namespace IRaCIS.Core.Infra.EFCore } - - - - /// EF跟踪方式 外层先有查询好的完成实体,再更新部分字段 稽查的时候需要完整的实体信息 - public async Task PartialUpdateAsync(TEntity waitModifyEntity, Expression> 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> updateFilter, Expression> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default) @@ -259,6 +243,22 @@ namespace IRaCIS.Core.Infra.EFCore } + /// EF跟踪方式 外层先有查询好的完成实体,再更新部分字段 稽查的时候需要完整的实体信息 + public async Task PartialUpdateAsync(TEntity waitModifyEntity, Expression> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default) + { + var entityEntry = _dbContext.Entry(waitModifyEntity); + entityEntry.State = EntityState.Detached; + + + ModifyPartialFiled(waitModifyEntity, updateFactory); + + return await SaveChangesAsync(autoSave); + + } + + + + /// EF跟踪方式 先查询出来,再更新部分字段 稽查的时候需要完整的实体信息 public async Task QueryThenPartiallyUpdateAsync(Guid id, Expression> updateFactory, bool autoSave = false, CancellationToken cancellationToken = default) @@ -298,6 +298,8 @@ namespace IRaCIS.Core.Infra.EFCore _dbContext.Entry(waitModifyEntity).Property(prop.Name).IsModified = true; } + + }