diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs index ce919454c..996733e7d 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/Storageable.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -423,8 +424,14 @@ namespace SqlSugar } public IStorageable WhereColumns(Expression> columns) { + if (columns == null) return this; + else if (asname == null && typeof(T).GetCustomAttribute() != null) + { + whereExpression = columns; + return this; + } else { List list = GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => Builder.GetNoTranslationColumnName(it)).ToList(); diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/StorageableSplitProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/StorageableSplitProvider.cs index 1d893dcff..d2b8664e3 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/StorageableSplitProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SaveableProvider/StorageableSplitProvider.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -13,6 +14,8 @@ namespace SqlSugar internal SqlSugarProvider Context { get; set; } internal List List { get; set; } internal EntityInfo EntityInfo { get; set; } + internal Expression> whereExpression { get; set; } + internal int pageSize = 1000; internal Action ActionCallBack =null; public StorageableSplitProvider PageSize(int size, Action ActionCallBack = null) @@ -111,7 +114,7 @@ namespace SqlSugar foreach (var item in groupModels.GroupBy(it => it.GroupName)) { var addList = item.Select(it => it.Item).ToList(); - resultValue +=await this.Context.Storageable(addList).As(item.Key).ExecuteCommandAsync(); + resultValue +=await this.Context.Storageable(addList).As(item.Key).WhereColumns(whereExpression).ExecuteCommandAsync(); if (ActionCallBack != null) { ActionCallBack(resultValue); @@ -128,7 +131,7 @@ namespace SqlSugar foreach (var item in groupModels.GroupBy(it => it.GroupName)) { var addList = item.Select(it => it.Item).ToList(); - resultValue += this.Context.Storageable(addList).As(item.Key).ExecuteCommand(); + resultValue += this.Context.Storageable(addList).As(item.Key).WhereColumns(whereExpression).ExecuteCommand(); } return result; } @@ -142,7 +145,7 @@ namespace SqlSugar foreach (var item in groupModels.GroupBy(it => it.GroupName)) { var addList = item.Select(it => it.Item).ToList(); - resultValue += await this.Context.Storageable(addList).As(item.Key).ExecuteSqlBulkCopyAsync(); + resultValue += await this.Context.Storageable(addList).As(item.Key).WhereColumns(whereExpression).ExecuteSqlBulkCopyAsync(); if (ActionCallBack != null) { ActionCallBack(resultValue); @@ -159,7 +162,7 @@ namespace SqlSugar foreach (var item in groupModels.GroupBy(it => it.GroupName)) { var addList = item.Select(it => it.Item).ToList(); - resultValue += this.Context.Storageable(addList).As(item.Key).ExecuteSqlBulkCopy(); + resultValue += this.Context.Storageable(addList).As(item.Key).WhereColumns(whereExpression).ExecuteSqlBulkCopy(); } return result; }