public void Create(SqlServerProcessor processor, IEnumerable <string> columnDefinitions) { if (!string.IsNullOrEmpty(_schemaName) && !processor.SchemaExists(_schemaName)) { using (var command = new SqlCommand(string.Format("CREATE SCHEMA {0}", _quoter.QuoteSchemaName(_schemaName)), Connection, Transaction)) command.ExecuteNonQuery(); } var quotedObjectName = _quoter.QuoteTableName(Name, _schemaName); var sb = new StringBuilder(); sb.AppendFormat("CREATE TABLE "); sb.Append(quotedObjectName); sb.Append("("); foreach (string definition in columnDefinitions) { sb.Append(definition); sb.Append(", "); } sb.Remove(sb.Length - 2, 2); sb.Append(")"); using (var command = new SqlCommand(sb.ToString(), Connection, Transaction)) command.ExecuteNonQuery(); }
private void Init(HanaProcessor processor, IEnumerable <string> columnDefinitions) { NameWithSchema = quoter.QuoteTableName(Name, _schemaName); Connection = (HanaConnection)processor.Connection; Transaction = (HanaTransaction)processor.Transaction; Create(columnDefinitions); }
public Db2TestTable(Db2Processor processor, string schema, params string[] columnDefinitions) { Processor = processor; _schema = schema; if (Connection.State != ConnectionState.Open) { Connection.Open(); } Name = "TestTable"; NameWithSchema = _quoter.QuoteTableName(Name, _schema); Create(columnDefinitions); }
private void Init(HanaProcessor processor, IEnumerable <string> columnDefinitions) { NameWithSchema = _quoter.QuoteTableName(Name, _schemaName); Connection = (HanaConnection)processor.Connection; Transaction = (HanaTransaction)processor.Transaction; if (Connection.State != ConnectionState.Open) { Connection.Open(); } Create(columnDefinitions); }
public Db2ISeriesTestTable(Db2Processor processor, string schema, params string[] columnDefinitions) { Connection = processor.Connection; Transaction = processor.Transaction; Processor = processor; Factory = new Db2DbFactory(); _schema = schema; if (Connection.State != ConnectionState.Open) { Connection.Open(); } Name = "TestTable"; NameWithSchema = quoter.QuoteTableName(Name, _schema); Create(columnDefinitions); }
public void Create(IEnumerable <string> columnDefinitions) { var sb = CreateSchemaQuery(); sb.Append("CREATE TABLE "); sb.Append(_quoter.QuoteTableName(Name)); foreach (string definition in columnDefinitions) { sb.Append("("); sb.Append(definition); sb.Append("), "); } sb.Remove(sb.Length - 2, 2); _processor.Execute(sb.ToString()); }
public void Create(IEnumerable <string> columnDefinitions) { var sb = CreateSchemaQuery(); sb.Append("CREATE TABLE "); sb.Append(quoter.QuoteTableName(Name)); foreach (string definition in columnDefinitions) { sb.Append("("); sb.Append(definition); sb.Append("), "); } sb.Remove(sb.Length - 2, 2); using (var command = Factory.CreateCommand(sb.ToString(), Connection, Transaction, 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))); }