!28 解决Storageable缓慢的问题

Merge pull request !28 from 啊脑袋/master
This commit is contained in:
sunkaixuan 2022-11-29 05:19:16 +00:00 committed by Gitee
commit 1a4997ec4f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 21 additions and 6 deletions

View File

@ -31,6 +31,13 @@ namespace SqlSugar
}).ToList();
}
Expression<Func<T, bool>> queryableWhereExp;
public IStorageable<T> TableDataRange(Expression<Func<T, bool>> exp)
{
this.queryableWhereExp = exp;
return this;
}
public IStorageable<T> SplitInsert(Func<StorageableInfo<T>, bool> conditions, string message = null)
{
whereFuncs.Add(new KeyValuePair<StorageType, Func<StorageableInfo<T>, bool>, string>(StorageType.Insert, conditions, message));
@ -299,13 +306,20 @@ namespace SqlSugar
}
if (whereColumns.Count > 0)
{
this.Context.Utilities.PageEach(allDatas, 200, itemList =>
if (queryableWhereExp == null)
{
List<IConditionalModel> conditList = new List<IConditionalModel>();
SetConditList(itemList, whereColumns, conditList);
var addItem = this.Context.Queryable<T>().AS(asname).Where(conditList).ToList();
this.dbDataList.AddRange(addItem);
});
this.Context.Utilities.PageEach(allDatas, 200, itemList =>
{
List<IConditionalModel> conditList = new List<IConditionalModel>();
SetConditList(itemList, whereColumns, conditList);
var addItem = this.Context.Queryable<T>().AS(asname).Where(conditList).ToList();
this.dbDataList.AddRange(addItem);
});
}
else
{
this.dbDataList.AddRange(this.Context.Queryable<T>().AS(asname).Where(queryableWhereExp).ToList());
}
}
this.whereExpression = columns;
return this;

View File

@ -8,6 +8,7 @@ namespace SqlSugar
{
public interface IStorageable<T> where T : class, new()
{
IStorageable<T> TableDataRange(Expression<Func<T, bool>> exp);
IStorageable<T> WhereColumns(Expression<Func<T, object>> columns);
IStorageable<T> WhereColumns(Expression<Func<T, object>> columns,Func<DateTime,string> formatTime);
IStorageable<T> WhereColumns(string [] columns);