public static ICreateTableWithColumnOrSchemaSyntax SmallIntForeignKeyIndexed(this ICreateTableWithColumnOrSchemaSyntax self, string name, string foreignTable, bool isNullable, bool isPK) { ICreateTableColumnOptionOrWithColumnSyntax col; if (isNullable) { col = self.WithColumn(name).AsInt16().Nullable().ForeignKey(foreignTable, "id"); } else { col = self.WithColumn(name).AsInt16().NotNullable().ForeignKey(foreignTable, "id"); } if (isPK) { col.PrimaryKey(); } else { col.Indexed(); } return(self); }
public static ICreateTableColumnOptionOrWithColumnSyntax WithIdColumn(this ICreateTableWithColumnOrSchemaSyntax createTable) { return(createTable.WithColumn("Id") .AsInt64() .NotNullable() .PrimaryKey() .Identity()); }
/// <summary> /// Ordinary Changeinfo with relations /// </summary> /// <param name="self"></param> /// <returns></returns> public static ICreateTableWithColumnOrSchemaSyntax ChangeInfo(this ICreateTableWithColumnOrSchemaSyntax self) { self.WithColumn("DateCreated").AsDateTime().NotNullable().WithDefaultValue(new SQLServerFunction("getutcdate()")) .WithColumn("CreatedByUserId").AsInt32().NotNullable().ForeignKey(Tables.User, "Id").Indexed() .WithColumn("LastModified").AsDateTime().NotNullable().WithDefaultValue(new SQLServerFunction("getutcdate()")) .WithColumn("LastModifiedByUserId").AsInt32().Nullable().ForeignKey(Tables.User, "Id").Indexed(); return(self); }
public static ICreateTableColumnOptionOrWithColumnSyntax WithDefaultColumns( this ICreateTableWithColumnOrSchemaSyntax table) { return(table.WithColumn("Id").AsInt64().PrimaryKey().Identity() .WithColumn("CreatedOn").AsDateTime() .WithColumn("CreatedBy").AsString().Nullable() .WithColumn("ModifiedOn").AsDateTime() .WithColumn("ModifiedBy").AsString().Nullable()); }
public static ICreateTableWithColumnOrSchemaSyntax Text(this ICreateTableWithColumnOrSchemaSyntax self, string name, bool isNullable) { if (isNullable) { self.WithColumn(name).AsCustom(PostgresSpecificType.Text).Nullable(); } else { self.WithColumn(name).AsCustom(PostgresSpecificType.Text).NotNullable(); } return(self); }
public static ICreateTableWithColumnOrSchemaSyntax TimestampzAndDefault(this ICreateTableWithColumnOrSchemaSyntax self, string name, bool isNullable) { if (isNullable) { self.WithColumn(name).AsCustom(PostgresSpecificType.Timestampz).Nullable(); } else { self.WithColumn(name).AsCustom(PostgresSpecificType.Timestampz).NotNullable().WithDefaultValue(PostgresFunction.NowTimestampzUTC); } return(self); }
public static ICreateTableWithColumnOrSchemaSyntax IntForeignKey(this ICreateTableWithColumnOrSchemaSyntax self, string name, string foreignTable, bool isNullable, bool isUnique = false, bool isPK = false, bool onDeleteCascade = false) { ICreateTableColumnOptionOrWithColumnSyntax col; var rule = onDeleteCascade ? System.Data.Rule.Cascade : System.Data.Rule.None; if (isUnique) { col = self.WithColumn(name).AsInt32().ForeignKey(foreignTable, "Id").OnDelete(rule).Unique(); } else { col = self.WithColumn(name).AsInt32().ForeignKey(foreignTable, "Id").OnDelete(rule); if (!isPK) { col.Indexed(); } } if (isNullable) { col.Nullable(); } else { col.NotNullable(); } if (isPK) { col.PrimaryKey(); } return(self); }
internal static ICreateTableColumnOptionOrWithColumnSyntax AutoIdBig(this ICreateTableWithColumnOrSchemaSyntax self) => self.WithColumn("id").AsCustom(PostgresSpecificType.IdentityBig).NotNullable().PrimaryKey();
public static ICreateTableColumnOptionOrWithColumnSyntax IsTest(this ICreateTableWithColumnOrSchemaSyntax self, bool defaultValue = false) => self.WithColumn("is_test").AsBoolean().NotNullable().WithDefaultValue(defaultValue);
public static ICreateTableColumnOptionOrWithColumnSyntax IsActive(this ICreateTableWithColumnOrSchemaSyntax self, bool defaultValue = true) => self.WithColumn("is_active").AsBoolean().NotNullable().WithDefaultValue(defaultValue);
public static ICreateTableColumnOptionOrWithColumnSyntax IdBig(this ICreateTableWithColumnOrSchemaSyntax self) => self.WithColumn("id").AsInt64().NotNullable().PrimaryKey();
public static ICreateTableWithColumnOrSchemaSyntax IntId(this ICreateTableWithColumnOrSchemaSyntax self) { self.WithColumn("Id").AsInt32().NotNullable().PrimaryKey(); return(self); }
public static ICreateTableColumnOptionOrWithColumnSyntax WithColumn(this ICreateTableWithColumnOrSchemaSyntax tableBuilder, string name, DbType dbType, int size) { return(ColumnExtensions.GetTypedColumn(tableBuilder.WithColumn(name), dbType, size)); }
public static ICreateTableColumnAsTypeSyntax WithColumn <TObject>(this ICreateTableWithColumnOrSchemaSyntax root, Expression <Func <TObject, object> > expression) { return(root.WithColumn(expression.ToMember().Name)); }