From b8c2028ac7043f72d3b82f67efcf204c94ea2fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=95=8A=E8=84=91=E8=A2=8B?= <534470428@qq.com> Date: Tue, 29 Nov 2022 12:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3Storageable=E7=BC=93=E6=85=A2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Abstract/SaveableProvider/Storageable.cs | 26 ++++++++++++++----- .../SqlSugar/Interface/IStorageable.cs | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs index 0c161b024..8932c369d 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs @@ -31,6 +31,13 @@ namespace SqlSugar }).ToList(); } + Expression> queryableWhereExp; + public IStorageable Where(Expression> exp) + { + this.queryableWhereExp = exp; + return this; + } + public IStorageable SplitInsert(Func, bool> conditions, string message = null) { whereFuncs.Add(new KeyValuePair, 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 conditList = new List(); - SetConditList(itemList, whereColumns, conditList); - var addItem = this.Context.Queryable().AS(asname).Where(conditList).ToList(); - this.dbDataList.AddRange(addItem); - }); + this.Context.Utilities.PageEach(allDatas, 200, itemList => + { + List conditList = new List(); + SetConditList(itemList, whereColumns, conditList); + var addItem = this.Context.Queryable().AS(asname).Where(conditList).ToList(); + this.dbDataList.AddRange(addItem); + }); + } + else + { + this.dbDataList.AddRange(this.Context.Queryable().AS(asname).Where(queryableWhereExp).ToList()); + } } this.whereExpression = columns; return this; diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/IStorageable.cs b/Src/Asp.NetCore2/SqlSugar/Interface/IStorageable.cs index 3c52d6da4..493b8d6c1 100644 --- a/Src/Asp.NetCore2/SqlSugar/Interface/IStorageable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Interface/IStorageable.cs @@ -8,6 +8,7 @@ namespace SqlSugar { public interface IStorageable where T : class, new() { + IStorageable Where(Expression> exp); IStorageable WhereColumns(Expression> columns); IStorageable WhereColumns(Expression> columns,Func formatTime); IStorageable WhereColumns(string [] columns);