@@ -58,7 +58,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||
Task<bool> BatchDeleteNoTrackingAsync(Expression<Func<TEntity, bool>> deleteFilter);
|
||||
|
||||
/// <summary>批量更新,相当于原生sql, 没用EF跟踪方式(所有查询出来,再更新 浪费性能)</summary>
|
||||
Task<bool> BatchUpdateNoTrackingAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory);
|
||||
Task<bool> BatchUpdateNoTrackingAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory, bool isAutoIncludeTimeAndUser = true);
|
||||
|
||||
Task<bool> ExecuteUpdateAsync(Expression<Func<TEntity, bool>> where, Expression<Func<SetPropertyCalls<TEntity>, SetPropertyCalls<TEntity>>> setPropertyCalls);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||
#endregion
|
||||
|
||||
|
||||
void MarkAsModified<TFrom>(TFrom entity, string propertyName);
|
||||
void MarkAsModified<TFrom>(TFrom entity, string propertyName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||
|
||||
|
||||
/// <summary>批量更新,相当于原生sql, 没用EF跟踪方式(所有查询出来,再更新 浪费性能)</summary>
|
||||
public static async Task<bool> BatchUpdateNoTrackingAsync<T>(this IRaCISDBContext _dbContext, Expression<Func<T, bool>> where, Expression<Func<T, T>> updateFactory, Guid updateUserId) where T : Entity
|
||||
public static async Task<bool> BatchUpdateNoTrackingAsync<T>(this IRaCISDBContext _dbContext, Expression<Func<T, bool>> where, Expression<Func<T, T>> updateFactory, Guid updateUserId, bool isAutoIncludeTimeAndUser = true) where T : Entity
|
||||
{
|
||||
if (where == null) throw new ArgumentNullException(nameof(where));
|
||||
|
||||
@@ -202,15 +202,17 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||
|
||||
if (typeof(IAuditUpdate).IsAssignableFrom(typeof(T)))
|
||||
{
|
||||
|
||||
if (!hasPropNameList.Contains(nameof(IAuditUpdate.UpdateTime)))
|
||||
if (isAutoIncludeTimeAndUser)
|
||||
{
|
||||
fieldValues.Add(nameof(IAuditUpdate.UpdateTime), DateTime.Now);
|
||||
}
|
||||
if (!hasPropNameList.Contains(nameof(IAuditUpdate.UpdateTime)))
|
||||
{
|
||||
fieldValues.Add(nameof(IAuditUpdate.UpdateTime), DateTime.Now);
|
||||
}
|
||||
|
||||
if (!hasPropNameList.Contains(nameof(IAuditUpdate.UpdateUserId)))
|
||||
{
|
||||
fieldValues.Add(nameof(IAuditUpdate.UpdateUserId), updateUserId);
|
||||
if (!hasPropNameList.Contains(nameof(IAuditUpdate.UpdateUserId)))
|
||||
{
|
||||
fieldValues.Add(nameof(IAuditUpdate.UpdateUserId), updateUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,10 +297,10 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||
|
||||
/// <summary>批量更新,相当于原生sql, 没用EF跟踪方式(所有查询出来,再更新 浪费性能)</summary>
|
||||
public async Task<bool> BatchUpdateNoTrackingAsync(Expression<Func<TEntity, bool>> where,
|
||||
Expression<Func<TEntity, TEntity>> updateFactory)
|
||||
Expression<Func<TEntity, TEntity>> updateFactory ,bool isAutoIncludeTimeAndUser = true)
|
||||
{
|
||||
|
||||
return await _dbContext.BatchUpdateNoTrackingAsync(where, updateFactory, _userInfo.UserRoleId);
|
||||
return await _dbContext.BatchUpdateNoTrackingAsync(where, updateFactory, _userInfo.UserRoleId, isAutoIncludeTimeAndUser);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user