初步添加报警功能
This commit is contained in:
@@ -199,7 +199,7 @@ public abstract class BaseRepository<TEntity>
|
||||
/// </summary>
|
||||
/// <param name="number">要获取的实体数量。</param>
|
||||
/// <returns>包含指定数量实体对象的列表。</returns>
|
||||
protected async Task<List<TEntity>> TakeAsync(int number)
|
||||
public virtual async Task<List<TEntity>> TakeAsync(int number)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
@@ -210,6 +210,23 @@ public abstract class BaseRepository<TEntity>
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步根据主键 ID 删除单个实体。
|
||||
/// </summary>
|
||||
/// <param name="id">要删除的实体的主键 ID。</param>
|
||||
/// <returns>返回受影响的行数。</returns>
|
||||
public virtual async Task<int> DeleteByIdAsync(int id)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var result = await Db.Deleteable<TEntity>()
|
||||
.In(id)
|
||||
.ExecuteCommandAsync();
|
||||
stopwatch.Stop();
|
||||
_logger.LogInformation($"DeleteById {typeof(TEntity).Name}, ID: {id}, 耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<bool> AddBatchAsync(List<TEntity> entities)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
|
||||
Reference in New Issue
Block a user