diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs
index 20a7c1836..de9cad4e7 100644
--- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs
+++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs
@@ -6,6 +6,7 @@ using System.Threading;
using System.Threading.Tasks;
using IRaCIS.Core.Domain.Models;
using Microsoft.EntityFrameworkCore.ChangeTracking;
+using Microsoft.EntityFrameworkCore.Query;
namespace IRaCIS.Core.Infra.EFCore
{
@@ -82,6 +83,8 @@ namespace IRaCIS.Core.Infra.EFCore
/// 批量更新,相当于原生sql, 没用EF跟踪方式(所有查询出来,再更新 浪费性能)
Task BatchUpdateNoTrackingAsync(Expression> where, Expression> updateFactory);
+ Task ExecuteUpdateAsync(Expression> where, Expression, SetPropertyCalls>> setPropertyCalls);
+
#endregion
diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs
index 1f0074074..25059eb64 100644
--- a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs
+++ b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs
@@ -232,12 +232,12 @@ namespace IRaCIS.Core.Infra.EFCore
}
- //public static async Task ExecuteUpdateAsync(this IRaCISDBContext _dbContext, Expression> where, Expression> updateFactory, Guid updateUserId) where T : Entity
- //{
+ public static async Task ExecuteUpdateAsync(this IRaCISDBContext _dbContext, Expression> where, Expression, SetPropertyCalls>> setPropertyCalls) where T : Entity
+ {
- // return await _dbContext.Set().Where(where).ExecuteUpdateAsync(, );
+ return await _dbContext.Set().Where(where).ExecuteUpdateAsync(setPropertyCalls)>0;
- //}
+ }
#endregion
diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs
index 7901a0a84..32f2520c4 100644
--- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs
+++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs
@@ -14,6 +14,7 @@ using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.Extensions.Localization;
+using Microsoft.EntityFrameworkCore.Query;
namespace IRaCIS.Core.Infra.EFCore
{
@@ -369,12 +370,17 @@ namespace IRaCIS.Core.Infra.EFCore
}
+ public async Task ExecuteUpdateAsync(Expression> where, Expression, SetPropertyCalls>> setPropertyCalls)
+ {
+ return await _dbContext.ExecuteUpdateAsync(where, setPropertyCalls);
+ }
+
#endregion
- #region 保存 、忽略 、验证
+ #region 保存 、忽略 、验证
public async Task InsertOrUpdateAsync(TFrom from, bool autoSave = false, params EntityVerifyExp[] verify)
{
var entity = _mapper.Map(from);