refactor:完成重构设备的添加,删除,更新。
This commit is contained in:
@@ -83,6 +83,16 @@ public abstract class BaseRepository<TEntity>
|
||||
_logger.LogInformation($"DeleteAsync Batch {typeof(TEntity).Name}, Count: {entities.Count}, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 异步批量删除实体。
|
||||
/// </summary>
|
||||
/// <param name="entities">要删除的实体列表。</param>
|
||||
/// <returns>返回受影响的行数。</returns>
|
||||
public virtual async Task<int> DeleteAsync(TEntity entity)
|
||||
{
|
||||
return await _dbContext.GetInstance().Deleteable(entity)
|
||||
.ExecuteCommandAsync(); ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -171,18 +181,12 @@ public abstract class BaseRepository<TEntity>
|
||||
|
||||
public async Task<List<TEntity>> AddAsync(List<TEntity> entities)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var retrunEntities = new List<TEntity>();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var result = await _dbContext.GetInstance().Insertable(entity).ExecuteReturnEntityAsync();
|
||||
retrunEntities.Add(result);
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
_logger.LogInformation($"AddBatchAsync {typeof(TEntity).Name}耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
|
||||
return retrunEntities;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user