protected new void ReplaceColumn <T>(string tableName, string currentName, string newName)
        {
            if (DatabaseType.IsSqlCe())
            {
                AddColumn <T>(tableName, newName, out var sqls);
                Execute.Sql($"UPDATE {SqlSyntax.GetQuotedTableName(tableName)} SET {SqlSyntax.GetQuotedColumnName(newName)}={SqlSyntax.GetQuotedColumnName(currentName)}").Do();
                foreach (var sql in sqls)
                {
                    Execute.Sql(sql).Do();
                }
                Delete.Column(currentName).FromTable(tableName).Do();
            }
            else
            {
                // TODO: Adding column just to get the SQL to execute after the rename
                AddColumn <T>(tableName, newName, out var sqls);
                Delete.Column(currentName).FromTable(tableName).Do();

                Execute.Sql(SqlSyntax.FormatColumnRename(tableName, currentName, newName)).Do();
                foreach (var sql in sqls)
                {
                    Execute.Sql(sql).Do();
                }
            }
        }
        public override string ToString()
        {
            if (IsExpressionSupported() == false)
            {
                return(string.Empty);
            }

            return(SqlSyntax.FormatColumnRename(TableName, OldName, NewName));
        }
 protected void ReplaceColumn <T>(string tableName, string currentName, string newName)
 {
     if (DatabaseType.IsSqlCe())
     {
         AddColumn <T>(tableName, newName, out var sqls);
         Execute.Sql($"UPDATE {SqlSyntax.GetQuotedTableName(tableName)} SET {SqlSyntax.GetQuotedColumnName(newName)}={SqlSyntax.GetQuotedColumnName(currentName)}").Do();
         foreach (var sql in sqls)
         {
             Execute.Sql(sql).Do();
         }
         Delete.Column(currentName).FromTable(tableName).Do();
     }
     else
     {
         Execute.Sql(SqlSyntax.FormatColumnRename(tableName, currentName, newName)).Do();
         AlterColumn <T>(tableName, newName);
     }
 }
Exemple #4
0
 protected void ReplaceColumn <T>(string tableName, string currentName, string newName)
 {
     Execute.Sql(SqlSyntax.FormatColumnRename(tableName, currentName, newName)).Do();
     AlterColumn <T>(tableName, newName);
 }
Exemple #5
0
 /// <inheritdoc />
 protected override string GetSql()
 {
     return(SqlSyntax.FormatColumnRename(TableName, OldName, NewName));
 }
Exemple #6
0
 private string GetBaseSql()
 {
     return(SqlSyntax.FormatColumnRename(TableName, OldName, NewName));
 }