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 SplitInsertable <T> SplitTable(SplitType splitType) { SplitTableContext helper = new SplitTableContext(Context) { EntityInfo = this.EntityInfo }; helper.CheckPrimaryKey(); SplitInsertable <T> result = new SplitInsertable <T>(); result.Context = this.Context; result.EntityInfo = this.EntityInfo; result.Helper = helper; result.SplitType = splitType; result.TableNames = new List <KeyValuePair <string, object> >(); foreach (var item in this.InsertObjs) { var splitFieldValue = helper.GetValue(splitType, item); var tableName = helper.GetTableName(splitType, splitFieldValue); result.TableNames.Add(new KeyValuePair <string, object>(tableName, item)); } result.Inserable = this; return(result); }