Split table

This commit is contained in:
sunkaixuna
2021-10-29 12:39:17 +08:00
parent dafbfd1d95
commit 651f7be540
6 changed files with 11 additions and 14 deletions

View File

@@ -12,9 +12,8 @@ namespace SqlSugar
public void InitTables<T>()
{
//var oldMapping = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
SplitTableContext helper = new SplitTableContext()
SplitTableContext helper = new SplitTableContext(Context)
{
Context = this.Context,
EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>()
};
helper.CheckPrimaryKey();

View File

@@ -263,9 +263,8 @@ namespace SqlSugar
this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName);
SplitTableDeleteProvider<T> result = new SplitTableDeleteProvider<T>();
result.Context = this.Context;
SplitTableContext helper = new SplitTableContext()
SplitTableContext helper = new SplitTableContext((SqlSugarProvider)Context)
{
Context =(SqlSugarProvider)Context,
EntityInfo = this.EntityInfo
};
var tables = getTableNamesFunc(helper.GetTables());

View File

@@ -408,10 +408,9 @@ namespace SqlSugar
}
public SplitInsertable<T> SplitTable(SplitType splitType)
{
SplitTableContext helper = new SplitTableContext()
SplitTableContext helper = new SplitTableContext(Context)
{
Context = this.Context,
EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>()
EntityInfo = this.EntityInfo
};
helper.CheckPrimaryKey();
SplitInsertable<T> result = new SplitInsertable<T>();

View File

@@ -836,10 +836,9 @@ namespace SqlSugar
}
public ISugarQueryable<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc)
{
SplitTableContext helper = new SplitTableContext()
{
Context=Context,
EntityInfo=this.EntityInfo
SplitTableContext helper = new SplitTableContext(Context)
{
EntityInfo = this.EntityInfo
};
this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName);
var tables = getTableNamesFunc(helper.GetTables());

View File

@@ -94,9 +94,8 @@ namespace SqlSugar
this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName);
SplitTableUpdateProvider<T> result = new SplitTableUpdateProvider<T>();
result.Context = this.Context;
SplitTableContext helper = new SplitTableContext()
SplitTableContext helper = new SplitTableContext(Context)
{
Context = (SqlSugarProvider)Context,
EntityInfo = this.EntityInfo
};
var tables = getTableNamesFunc(helper.GetTables());

View File

@@ -12,8 +12,10 @@ namespace SqlSugar
public SqlSugarProvider Context { get; set; }
public EntityInfo EntityInfo { get; set; }
public ISplitTableService Service { get; set; }
public SplitTableContext()
private SplitTableContext() { }
public SplitTableContext(SqlSugarProvider context)
{
this.Context = context;
if (this.Context.CurrentConnectionConfig.ConfigureExternalServices != null&&this.Context.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService!=null)
{
Service = this.Context.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService;