feature:给所有仓储类都添加批量更新方法
This commit is contained in:
@@ -151,6 +151,24 @@ public abstract class BaseRepository<TEntity>
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步批量更新实体。
|
||||
/// </summary>
|
||||
/// <param name="entities">要更新的实体列表。</param>
|
||||
/// <returns>返回受影响的行数。</returns>
|
||||
public virtual async Task<int> UpdateAsync(List<TEntity> entities)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var result = await _dbContext.GetInstance().Updateable(entities)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
_logger.LogInformation($"UpdateAsync Batch {typeof(TEntity).Name}, Count: {entities.Count}, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<TEntity>> AddAsync(List<TEntity> entities)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
@@ -165,7 +183,6 @@ public abstract class BaseRepository<TEntity>
|
||||
stopwatch.Stop();
|
||||
_logger.LogInformation($"AddBatchAsync {typeof(TEntity).Name}耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
|
||||
|
||||
return retrunEntities;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user