private static void ProcessType(string type, ICreateTableColumnAsTypeSyntax column)
        {
            switch (type)
            {
            case "short":
            case "int16":
                column.AsInt16();
                break;

            case "int":
            case "int32":
                column.AsInt32();
                break;

            case "datetime":
                column.AsDateTime();
                break;

            case "guid":
                column.AsGuid();
                break;

            case "string":
            default:
                column.AsString();
                break;
            }
        }
Esempio n. 2
0
    public static ICreateTableColumnOptionOrForeignKeyCascadeOrWithColumnSyntax AsForeignKeyReference(
        this ICreateTableColumnAsTypeSyntax column,
        string foreignTable,
        string idColumn      = "Id",
        bool deleteOnCascade = true)
    {
        var attrs = column.AsInt64().ForeignKey(foreignTable, idColumn);

        return(deleteOnCascade ? attrs.OnDelete(Rule.Cascade) : attrs);
    }
Esempio n. 3
0
        public static ICreateTableColumnOptionOrWithColumnSyntax AsMyDateTime(
            this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax)
        {
            if (!DbProvider.IsPostgre)
            {
                return(createTableColumnAsTypeSyntax.AsDateTime());
            }

            return(createTableColumnAsTypeSyntax.AsCustom("TimestampTz"));
        }
Esempio n. 4
0
        public static ICreateTableColumnOptionOrWithColumnSyntax AsVarcharString(
            this ICreateTableColumnAsTypeSyntax columnTypeSyntax,
            int size,
            bool nullable = false)
        {
            var customType   = string.Format(@"VARCHAR({0})", size);
            var intermediate = columnTypeSyntax.AsCustom(customType);

            return(nullable ? intermediate.Nullable() : intermediate.NotNullable());
        }
        //public override void Up()
        //{
        //    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("");
        //    }

        //}

        public override void Up()
        {
            var tableList = json.table;
            var col       = json.col;
            var reference = json.reference;

            var builder = Create;

            foreach (var tableItem in tableList)
            {
                ICreateTableWithColumnOrSchemaOrDescriptionSyntax tableBuilder = builder.Table(tableItem["name"].Value);

                foreach (var colItem in col[tableItem["name"].Value])
                {
                    ICreateTableColumnAsTypeSyntax column = tableBuilder.WithColumn(colItem.Name);
                    ProcessType(colItem.Value.Value, column);
                }
            }
        }
Esempio n. 6
0
        public void Up12()
        {
            var tableList = json.table;
            var col       = json.col;
            var reference = json.reference;

            var builder = Create;

            foreach (var tableItem in tableList)
            {
                ICreateTableWithColumnOrSchemaOrDescriptionSyntax tableBuilder = builder.Table(tableItem["name"].Value);

                //tableBuilder.WithColumn("Id").AsGuid().PrimaryKey();

                foreach (var colItem in col[tableItem["name"].Value])
                {
                    ICreateTableColumnAsTypeSyntax column = tableBuilder.WithColumn(colItem.Name);
                    //ProcessType(colItem.Value.ToString().ToLower(), column);
                }
            }
        }
Esempio n. 7
0
 public static ICreateTableColumnOptionOrWithColumnSyntax AsMaxString(this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax)
 {
     //return createTableColumnAsTypeSyntax.AsCustom("nvarchar(max)");
     return(createTableColumnAsTypeSyntax.AsString(int.MaxValue));
 }
        public static ICreateTableColumnOptionOrWithColumnSyntax AsCardVendorId(this ICreateTableColumnAsTypeSyntax syntax)
        {
            const int length = 16;

            return(syntax.AsString(length));
        }
 public static ICreateTableColumnOptionOrWithColumnSyntax AsUserId(this ICreateTableColumnAsTypeSyntax syntax)
 {
     return(syntax.AsGuid());
 }
        public static ICreateTableColumnOptionOrWithColumnSyntax AsCurrencyISOName(this ICreateTableColumnAsTypeSyntax syntax)
        {
            const int length = 3;

            return(syntax.AsString(length));
        }
        public static ICreateTableColumnOptionOrWithColumnSyntax AsAccountNumber(this ICreateTableColumnAsTypeSyntax syntax)
        {
            const int length = 13;

            return(syntax.AsString(length));
        }
 public static ICreateTableColumnOptionOrWithColumnSyntax AsStringIdColumn(this ICreateTableColumnAsTypeSyntax syntax)
 {
     return(syntax.AsString(128).NotNullable().PrimaryKey());
 }
Esempio n. 13
0
 public static ICreateTableColumnOptionOrWithColumnSyntax AsDateTimeOffset(this ICreateTableColumnAsTypeSyntax create)
 {
     return(create.AsCustom("DateTimeOffset"));
 }
Esempio n. 14
0
 public static ICreateTableColumnOptionOrWithColumnSyntax AsTINYINT(this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax)
 {
     return(createTableColumnAsTypeSyntax.AsCustom("tinyint"));
 }
Esempio n. 15
0
 public static ICreateTableWithColumnSyntax AsId(this ICreateTableColumnAsTypeSyntax column)
 {
     return(column.AsInt64().NotNullable().PrimaryKey().Identity());
 }
 /// <summary>
 /// Creates column as a standard auto-increment 32 bit integer ID primary key column
 /// </summary>
 public static ICreateTableColumnOptionOrWithColumnSyntax AsIdColumn(this ICreateTableColumnAsTypeSyntax syntax)
 {
     return(syntax.AsInt32().Identity().NotNullable().PrimaryKey());
 }
Esempio n. 17
0
 public static ICreateTableWithColumnSyntax AsReference(this ICreateTableColumnAsTypeSyntax column)
 {
     return(column.AsInt64().NotNullable());
 }
Esempio n. 18
0
 public static ICreateTableColumnOptionOrWithColumnSyntax AsJson(
     this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax)
 {
     return(createTableColumnAsTypeSyntax.AsCustom("Json"));
 }
Esempio n. 19
0
 public static ICreateTableColumnOptionOrWithColumnSyntax AsText(this ICreateTableColumnAsTypeSyntax that)
 {
     return(that.AsString(int.MaxValue));
 }
        public static ICreateTableColumnOptionOrWithColumnSyntax AsPaymentCode(this ICreateTableColumnAsTypeSyntax syntax)
        {
            const int length = 4;

            return(syntax.AsString(length));
        }
Esempio n. 21
0
 public static ICreateTableColumnOptionOrWithColumnSyntax AsStringMax(
     this ICreateTableColumnAsTypeSyntax column
     )
 {
     return(column.AsString(10000));
 }
        public static ICreateTableColumnOptionOrWithColumnSyntax AsSecurityString(this ICreateTableColumnAsTypeSyntax syntax)
        {
            const int length = 256;

            return(syntax.AsString(length));
        }
Esempio n. 23
0
 /// <summary>
 /// Extension method for creating text column with maximal size
 /// </summary>
 /// <param name="createTableColumnAsTypeSyntax"></param>
 /// <returns></returns>
 public static ICreateTableColumnOptionOrWithColumnSyntax AsMaxString(this ICreateTableColumnAsTypeSyntax createTableColumnAsTypeSyntax)
 {
     return(createTableColumnAsTypeSyntax.AsString(int.MaxValue));
 }
 public static ICreateTableColumnOptionOrWithColumnSyntax AsMaxString(this ICreateTableColumnAsTypeSyntax syntax)
 {
     return(syntax.AsCustom("nvarchar(MAX)"));
 }