Esempio n. 1
0
        public override void Up()
        {
            var tool = new DataJsonDiff();

            var inTable  = tool.InCommingTables(json, srcJson);
            var outTable = tool.OutCommingTables(json, srcJson);

            var inCol  = tool.InCommingColumns(json, srcJson);
            var outCol = tool.OutCommingColumn(json, srcJson);

            var inRel  = tool.InCommingRelation(json, srcJson);
            var outRel = tool.OutCommingRelation(json, srcJson);

            var builder = Create;

            foreach (var item in inTable)
            {
                ICreateTableWithColumnOrSchemaOrDescriptionSyntax tableBuilder = builder.Table(item);
                tableBuilder.WithColumn("Id").AsGuid();
            }

            foreach (var item in inCol)
            {
                var colOnTableName = FindTableName(item.Key, json.tables);
                foreach (var colItem in item.Value)
                {
                    ICreateColumnOnTableSyntax colBuilder       = Create.Column(colItem.name.Value);
                    ICreateColumnAsTypeSyntax  coOptionlBuilder = colBuilder.OnTable(colOnTableName);
                    //coOptionlBuilder.AsString();
                    ProcessType(colItem.type.Value, coOptionlBuilder);
                }
            }

            foreach (var item in inRel)
            {
                ICreateForeignKeyFromTableSyntax relationBuilder = Create.ForeignKey(item);
                string tableName = json.tables[item.tableId].Value;
                relationBuilder.FromTable(tableName).ForeignColumn("").ToTable("").PrimaryColumn("");
            }

            var DelBuilder = Delete;

            foreach (var item in outTable)
            {
                DelBuilder.Table(item);
            }

            foreach (var item in outCol)
            {
                DelBuilder.Column("").FromTable("");
            }

            foreach (var item in outRel)
            {
                DelBuilder.ForeignKey("").OnTable("");
            }
        }
Esempio n. 2
0
        public static ICreateForeignKeyCascadeSyntax BetweenEntities <TForeignEntity, TPrimaryEntity>(this ICreateForeignKeyFromTableSyntax root, string foreignColumnName = null)
            where TForeignEntity : class, IEntity
            where TPrimaryEntity : class, IEntity
        {
            var foreignTableName = TableName.ForEntity <TForeignEntity>();

            foreignColumnName = foreignColumnName ?? ColumnName.ForeignKeyTo <TPrimaryEntity>();

            var primaryTableName  = TableName.ForEntity <TPrimaryEntity>();
            var primaryColumnName = ColumnName.PrimaryKey;

            return(root
                   .FromTable(foreignTableName).ForeignColumn(foreignColumnName)
                   .ToTable(primaryTableName).PrimaryColumn(primaryColumnName));
        }
Esempio n. 3
0
 public static ICreateForeignKeyForeignColumnSyntax FromTable <T>(this ICreateForeignKeyFromTableSyntax alter) where T : new()
 {
     return(alter.FromTable(TableNameAttribute <T>()));
 }