Quote() public method

public Quote ( string value ) : string
value string
return string
コード例 #1
0
 public virtual void RemoveConstraint(string table, string name)
 {
     if (TableExists(table) && ConstraintExists(table, name))
     {
         table = _dialect.TableNameNeedsQuote ? _dialect.Quote(table) : table;
         name  = _dialect.ConstraintNameNeedsQuote ? _dialect.Quote(name) : name;
         ExecuteNonQuery(String.Format("ALTER TABLE {0} DROP CONSTRAINT {1}", table, name));
     }
 }
コード例 #2
0
 public virtual string QuoteTableNameIfRequired(string name)
 {
     if (Dialect.TableNameNeedsQuote || Dialect.IsReservedWord(name))
     {
         return(Dialect.Quote(name));
     }
     return(name);
 }
コード例 #3
0
        public virtual void RemoveColumn(string table, string column)
        {
            if (!ColumnExists(table, column))
            {
                throw new MigrationException(string.Format("The table '{0}' does not have a column named '{1}'", table, column));
            }

            var existingColumn = GetColumnByName(table, column);

            ExecuteNonQuery(String.Format("ALTER TABLE {0} DROP COLUMN {1} ", table, Dialect.Quote(existingColumn.Name)));
        }
コード例 #4
0
        public virtual void RenameColumn(string tableName, string oldColumnName, string newColumnName)
        {
            if (ColumnExists(tableName, newColumnName))
            {
                throw new MigrationException(String.Format("Table '{0}' has column named '{1}' already", tableName, newColumnName));
            }

            if (!ColumnExists(tableName, oldColumnName))
            {
                throw new MigrationException(string.Format("The table '{0}' does not have a column named '{1}'", tableName, oldColumnName));
            }

            var column = GetColumnByName(tableName, oldColumnName);

            var quotedNewColumnName = QuoteColumnNameIfRequired(newColumnName);

            ExecuteNonQuery(String.Format("ALTER TABLE {0} RENAME COLUMN {1} TO {2}", tableName, Dialect.Quote(column.Name), quotedNewColumnName));
        }