Esempio n. 1
0
        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;
 }
Esempio n. 3
0
        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);
        }