完成删除变量

This commit is contained in:
2025-08-24 17:48:33 +08:00
parent c813fe63c3
commit 1d8d4a7f5e
9 changed files with 171 additions and 266 deletions

View File

@@ -116,6 +116,23 @@ public abstract class BaseRepository<TEntity>
return entity;
}
/// <summary>
/// 异步根据主键 ID 列表批量删除实体。
/// </summary>
/// <param name="ids">要删除的实体主键 ID 列表。</param>
/// <returns>返回受影响的行数。</returns>
public virtual async Task<int> DeleteByIdsAsync(List<int> ids)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var result = await Db.Deleteable<TEntity>()
.In(ids)
.ExecuteCommandAsync();
stopwatch.Stop();
NlogHelper.Info($"DeleteByIds {typeof(TEntity).Name}, Count: {ids.Count}, 耗时:{stopwatch.ElapsedMilliseconds}ms");
return result;
}
/// <summary>
/// 异步根据指定条件获取单个实体。
/// </summary>