Update db.Storageable.WhereColumn.Splitable()

This commit is contained in:
sunkaixuan
2023-09-01 18:26:50 +08:00
parent 4d2badb9e6
commit 35e3aa85f7
2 changed files with 14 additions and 4 deletions

View File

@@ -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<T> WhereColumns(Expression<Func<T, object>> columns)
{
if (columns == null)
return this;
else if (asname == null && typeof(T).GetCustomAttribute<SplitTableAttribute>() != null)
{
whereExpression = columns;
return this;
}
else
{
List<string> list = GetExpressionValue(columns, ResolveExpressType.ArraySingle).GetResultArray().Select(it => Builder.GetNoTranslationColumnName(it)).ToList();

View File

@@ -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<T> List { get; set; }
internal EntityInfo EntityInfo { get; set; }
internal Expression<Func<T, object>> whereExpression { get; set; }
internal int pageSize = 1000;
internal Action<int> ActionCallBack =null;
public StorageableSplitProvider<T> PageSize(int size, Action<int> 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;
}