从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace YLErp.Modules.TradeModule.QueryModule
|
||||
{
|
||||
public class BatchGetTradeRelationDataService<T> where T : DBModelBase
|
||||
{
|
||||
public List<T> GetListByWhere(Expression<Func<T, bool>> expression, DbSet<T> dataSet, int batchSize = 500)
|
||||
{
|
||||
var result = new List<T>();
|
||||
var newExpression = expression;
|
||||
while (true)
|
||||
{
|
||||
var list = dataSet.AsNoTracking().Where(newExpression).OrderBy(p => p.id).Take(batchSize).ToList();
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
result.AddRange(list);
|
||||
}
|
||||
if (list == null || list.Count < batchSize)
|
||||
{
|
||||
break;
|
||||
}
|
||||
var maxId = list.Max(p => p.id);
|
||||
newExpression = expression.And(p => p.id > maxId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user