添加TakeAsync方法。

This commit is contained in:
2025-07-22 21:36:33 +08:00
parent b881c89d96
commit fe3045c2d2
13 changed files with 86 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Linq.Expressions;
using DMS.Core.Helper;
using DMS.Core.Models;
using DMS.Infrastructure.Data;
using SqlSugar;
@@ -162,4 +163,15 @@ public abstract class BaseRepository<TEntity>
{
await Db.RollbackTranAsync();
}
protected async Task<List<TEntity>> TakeAsync(int number)
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var entity = await Db.Queryable<TEntity>().Take(number).ToListAsync();
stopwatch.Stop();
NlogHelper.Info($"TakeAsync {typeof(TEntity).Name}耗时:{stopwatch.ElapsedMilliseconds}ms");
return entity;
}
}