public void WithIndexOn(string column, string name) { var query = string.Format("CREATE UNIQUE INDEX {0} ON {1} ({2})", _quoter.QuoteIndexName(name, _schema), NameWithSchema, _quoter.QuoteColumnName(column) ); Processor.Execute(query); }
public void WithIndexOn(string column, string name) { var query = string.Format("CREATE UNIQUE INDEX {0} ON {1} ({2})", quoter.QuoteIndexName(name), NameWithSchema, quoter.QuoteColumnName(column) ); using (var command = Factory.CreateCommand(query, Connection, Transaction, Processor.Options)) { command.ExecuteNonQuery(); } }
public string Generate(CreateIndexExpression expression) { var indexColumns = new string[expression.Index.Columns.Count]; for (var i = 0; i < expression.Index.Columns.Count; i++) { var columnDef = expression.Index.Columns.ElementAt(i); if (columnDef.Direction == Direction.Ascending) { indexColumns[i] = Quoter.QuoteColumnName(columnDef.Name) + " ASC"; } else { indexColumns[i] = Quoter.QuoteColumnName(columnDef.Name) + " DESC"; } } return(string.Format(CreateIndexSqlTemplate , GetUniqueString(expression) , QuoteSchemaAndIdentifier(expression.Index.Name, expression.Index.SchemaName) , Quoter.QuoteTableName(expression.Index.TableName, expression.Index.SchemaName) , string.Join(", ", indexColumns))); }
public void CanHandleAnAlreadyQuotedColumnName() { _quoter.QuoteColumnName("\"ColumnName\"").ShouldBe("\"ColumnName\""); }
public void WithUniqueConstraintOn(string column, string name) { var sb = new StringBuilder(); sb.Append(string.Format("ALTER TABLE {0} ADD CONSTRAINT {1} UNIQUE ({2})", quoter.QuoteTableName(Name), quoter.QuoteConstraintName(name), quoter.QuoteColumnName(column))); using (var command = Factory.CreateCommand(sb.ToString(), Connection, Transaction, Options)) command.ExecuteNonQuery(); constraints.Add(name); }
public void WithUniqueConstraintOn(string column, string name) { var sb = new StringBuilder(); sb.Append(string.Format("ALTER TABLE {0} ADD CONSTRAINT {1} UNIQUE ({2})", _quoter.QuoteTableName(Name), _quoter.QuoteConstraintName(name), _quoter.QuoteColumnName(column))); _processor.Execute(sb.ToString()); _constraints.Add(name); }
public virtual string FormatString(ColumnDefinition column) { return(_quoter.QuoteColumnName(column.Name)); }
public string WithIndexOn(string column) { var indexName = string.Format("idx_{0}", column); var quotedObjectName = _quoter.QuoteTableName(Name, _schemaName); var quotedIndexName = _quoter.QuoteIndexName(indexName); indexies.Add(quotedIndexName); using (var command = new SqlCommand(string.Format("CREATE INDEX {0} ON {1} ({2})", quotedIndexName, quotedObjectName, _quoter.QuoteColumnName(column)), Connection, Transaction)) command.ExecuteNonQuery(); return(indexName); }
public void WithDefaultValueOn(string column) { const int defaultValue = 1; using (var command = new HanaCommand(string.Format(" ALTER TABLE {0} ALTER {1} SET DEFAULT {2}", _quoter.QuoteTableName(Name, _schemaName), _quoter.QuoteColumnName(column), defaultValue), Connection, Transaction)) command.ExecuteNonQuery(); }