public static void RenameColumn(this TransformationProvider database, string table, string oldName, string newName) { new RenameExpressionRoot(database.Context) .Column(oldName) .OnTable(table) .To(newName); }
public static void AddForeignKey(this TransformationProvider database, string name, string sourceTable, string[] sourceColumns, string destTable, string[] destColumns) { new CreateExpressionRoot(database.Context).ForeignKey(name) .FromTable(sourceTable) .ForeignColumns(sourceColumns) .ToTable(destTable) .PrimaryColumns(destColumns); }
public virtual void GetDownExpressions(IMigrationContext context) { lock (_lock) { ApplicationContext = context.ApplicationContext; Database = new TransformationProvider(context); Down(); Database = null; } }
public static void ChangeColumn(this TransformationProvider database, string table, Column column) { var columnBuilder = new AlterExpressionRoot(database.Context) .Column(column.Name) .OnTable(table); var typed = GetTypedColumn(columnBuilder, column.Type, column.Size); ApplyColumnOptions(typed, column.ColumnProperty, column.DefaultValue); }
public static void AddTable(this TransformationProvider database, string name, params Column[] columns) { var tableBuilder = new CreateExpressionRoot(database.Context).Table(name); foreach (var column in columns) { var builder = tableBuilder.WithColumn(column.Name, column.Type, column.Size); ColumnExtensions.ApplyColumnOptions(builder, column.ColumnProperty, column.DefaultValue); } }
public static void AddIndex(this TransformationProvider database, string indexName, string tableName, params string[] columns) { ICreateIndexOnColumnSyntax builder = new CreateExpressionRoot(database.Context).Index(indexName) .OnTable(tableName); foreach (var column in columns) { builder = builder.OnColumn(column).Ascending(); } }
public static void AddUniqueConstraint(this TransformationProvider database, string name, string table, params string[] columns) { var indexBuilder = new CreateExpressionRoot(database.Context).Index(name); var tabledIndexBuilder = indexBuilder.OnTable(table); foreach (string column in columns) { tabledIndexBuilder.OnColumn(column).Ascending(); } tabledIndexBuilder.WithOptions().Unique(); }
public static void ExecuteNonQuery(this TransformationProvider database, string sql) { new ExecuteExpressionRoot(database.Context) .Sql(sql); }
public static void AddCheckConstraint(this TransformationProvider database, string name, string table, string constraint) { database.ExecuteNonQuery("ALTER TABLE [{0}] ADD CONSTRAINT [{1}] CHECK ({2})", table, name, constraint); }
public static void RemoveConstraint(this TransformationProvider database, string table, string name) { database.ExecuteNonQuery("ALTER TABLE [{0}] DROP CONSTRAINT [{1}]", table, name); }
public static void AddForeignKey(this TransformationProvider database, string name, string sourceTable, string sourceColumn, string destTable, string destColumn) { database.AddForeignKey(name, sourceColumn, new[] { sourceColumn }, destTable, new[] { destColumn }); }
public static void RemoveForeignKey(this TransformationProvider database, string table, string keyName) { new DeleteExpressionRoot(database.Context).ForeignKey(keyName); }
public static void RemoveTable(this TransformationProvider database, string name) { new DeleteExpressionRoot(database.Context).Table(name); }
public static void RemoveIndex(this TransformationProvider database, string tableName, string indexName) { new DeleteExpressionRoot(database.Context) .Index(indexName) .OnTable(tableName); }
public static void Execute(this TransformationProvider database, Action <IDbConnection, IDbTransaction> action) { new ExecuteExpressionRoot(database.Context) .WithConnection(action); }
public static void ExecuteNonQuery(this TransformationProvider database, string sql, params object[] args) { sql = string.Format(sql, args); database.ExecuteNonQuery(sql); }
public static void RemoveColumn(this TransformationProvider database, string table, string column) { new DeleteExpressionRoot(database.Context) .Column(column) .FromTable(table); }