Browse Source

Split table

pull/9/head
sunkaixuna 3 years ago
parent
commit
010bf56234
  1. 1
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  2. 12
      Src/Asp.Net/SqlSugar/SpliteTable/SplitTypeExtensions.cs

1
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -851,6 +851,7 @@ namespace SqlSugar
{
tableQueryables.Add(this.Clone().AS(item.TableName));
}
Check.Exception(tableQueryables.Count == 0, ErrorMessage.GetThrowMessage("SplitTable error . There are no tables after filtering", "SplitTable没有筛选出分表,请检查条件和数据库中的表"));
var unionall = this.Context._UnionAll(tableQueryables.ToArray());
//var values= unionall.QueryBuilder.GetSelectValue;
//unionall.QueryBuilder.SelectValue = values;

12
Src/Asp.Net/SqlSugar/SpliteTable/SplitTypeExtensions.cs

@ -12,5 +12,17 @@ namespace SqlSugar
{
return tables.Where(it => tableNames.Any(y => y.Equals(it.TableName, StringComparison.OrdinalIgnoreCase)));
}
public static IEnumerable<SplitTableInfo> ContainsTableNames(this List<SplitTableInfo> tables, params string[] tableNames)
{
List<SplitTableInfo> result = new List<SplitTableInfo>();
foreach (var item in tables)
{
if (tableNames.Any(it => item.TableName.Contains(it)))
{
result.Add(item);
}
}
return result;
}
}
}

Loading…
Cancel
Save