public static void RenameColumn(this TransformationProvider database, string table, string oldName, string newName)
 {
     new RenameExpressionRoot(database.Context)
     .Column(oldName)
     .OnTable(table)
     .To(newName);
 }
示例#2
0
 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);
            }
        }
示例#6
0
        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();
            }
        }
示例#7
0
 public virtual void GetDownExpressions(IMigrationContext context)
 {
     lock (_lock)
     {
         ApplicationContext = context.ApplicationContext;
         Database           = new TransformationProvider(context);
         Down();
         Database = null;
     }
 }
示例#8
0
        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();
        }
示例#9
0
 public static void ExecuteNonQuery(this TransformationProvider database, string sql)
 {
     new ExecuteExpressionRoot(database.Context)
     .Sql(sql);
 }
示例#10
0
 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);
 }
示例#11
0
 public static void RemoveConstraint(this TransformationProvider database, string table, string name)
 {
     database.ExecuteNonQuery("ALTER TABLE [{0}] DROP CONSTRAINT [{1}]", table, name);
 }
示例#12
0
 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 });
 }
示例#13
0
 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);
 }
示例#15
0
 public static void RemoveIndex(this TransformationProvider database, string tableName, string indexName)
 {
     new DeleteExpressionRoot(database.Context)
     .Index(indexName)
     .OnTable(tableName);
 }
示例#16
0
 public static void Execute(this TransformationProvider database, Action <IDbConnection, IDbTransaction> action)
 {
     new ExecuteExpressionRoot(database.Context)
     .WithConnection(action);
 }
示例#17
0
 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);
 }