public void InitTables(Type type) { //var oldMapping = this.Context.Utilities.TranslateCopy(this.Context.MappingTables); SplitTableContext helper = new SplitTableContext(Context) { EntityInfo = this.Context.EntityMaintenance.GetEntityInfo(type) }; helper.CheckPrimaryKey(); var tables = helper.GetTables(); //var oldMapingTables = this.Context.MappingTables; if (tables.Count > 0) { foreach (var item in tables) { this.Context.MappingTables.Add(helper.EntityInfo.EntityName, item.TableName); this.Context.CodeFirst.InitTables(type); } } else { this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.GetDefaultTableName()); this.Context.CodeFirst.InitTables(type); } this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.EntityInfo.DbTableName); }
public SplitTableDeleteProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc) { this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName); SplitTableDeleteProvider<T> result = new SplitTableDeleteProvider<T>(); result.Context = this.Context; SplitTableContext helper = new SplitTableContext((SqlSugarProvider)Context) { EntityInfo = this.EntityInfo }; var tables = getTableNamesFunc(helper.GetTables()); result.Tables = tables; result.deleteobj = this; return result; }