本文整理汇总了C#中FluentMigrator.Expressions.CreateTableExpression类的典型用法代码示例。如果您正苦于以下问题:C# CreateTableExpression类的具体用法?C# CreateTableExpression怎么用?C# CreateTableExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateTableExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了CreateTableExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetCreateTableWithAutoIncrementExpression
public static CreateTableExpression GetCreateTableWithAutoIncrementExpression()
{
var expression = new CreateTableExpression { TableName = TestTableName1 };
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, IsIdentity = true, Type = DbType.Int32 });
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32 });
return expression;
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs
示例2: GetCreateTableExpression
public static CreateTableExpression GetCreateTableExpression()
{
CreateTableExpression expression = new CreateTableExpression() { TableName = TestTableName1, };
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, Type = DbType.String });
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32 });
return expression;
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs
示例3: ErrorIsReturnedWhenTableNameIsEmptyString
public void ErrorIsReturnedWhenTableNameIsEmptyString()
{
var expression = new CreateTableExpression { TableName = String.Empty };
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.TableNameCannotBeNullOrEmpty);
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:CreateTableExpressionTests.cs
示例4: CanMigrateTableWithIdentityData
public void CanMigrateTableWithIdentityData()
{
// Arrange
var create = new CreateTableExpression
{
TableName = "Foo"
,
Columns = new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32, IsIdentity = true} }
};
var context = GetDefaultContext();
var insert = new InsertDataExpression()
{
TableName = "Foo"
};
insert.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("Id", 1)});
insert.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("Id", 100) });
insert.WithIdentity = true;
// Act
MigrateTable(context, create, insert);
// Assert
context.MigrationIndex.ShouldBe(1);
}
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:25,代码来源:SqlServerMigrationTests.cs
示例5: ErrorIsNotReturnedWhenTableNameIsSet
public void ErrorIsNotReturnedWhenTableNameIsSet()
{
var expression = new CreateTableExpression { TableName = "table1" };
var errors = ValidationHelper.CollectErrors(expression);
Assert.That(errors.Count, Is.EqualTo(0));
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:CreateTableExpressionTests.cs
示例6: GetCreateTableWithNullableColumn
public static CreateTableExpression GetCreateTableWithNullableColumn()
{
var expression = new CreateTableExpression { TableName = TestTableName1 };
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, IsNullable = true, Type = DbType.String });
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32 });
return expression;
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs
示例7: Generate
public string Generate(CreateTableExpression expression)
{
IList<ColumnDefinition> columns = expression.Columns;
string result = "";
int total = columns.Count - 1;
//if more than one column is a primary key or the primary key is given a name, then it needs to be added separately
IList<ColumnDefinition> primaryKeyColumns = GetPrimaryKeyColumns(columns);
bool addPrimaryKeySeparately = false;
if (primaryKeyColumns.Count > 1 || (primaryKeyColumns.Count == 1 && !string.IsNullOrEmpty(primaryKeyColumns[0].PrimaryKeyName)))
{
if(CanSeperatePrimaryKeyAndIdentity || primaryKeyColumns.All(x => !x.IsIdentity))
{
addPrimaryKeySeparately = true;
foreach (ColumnDefinition column in primaryKeyColumns)
{
column.IsPrimaryKey = false;
}
}
}
for (int i = 0; i < columns.Count; i++)
{
result += Generate(columns[i]);
if (i != total)
result += ", ";
}
if (addPrimaryKeySeparately)
result = AddPrimaryKeyConstraint(expression.TableName, primaryKeyColumns, result);
return result;
}
开发者ID:Ang3lFir3,项目名称:fluentmigrator,代码行数:34,代码来源:ColumnBase.cs
示例8: GetCreateTableWithNamedMultiColumnPrimaryKeyExpression
public static CreateTableExpression GetCreateTableWithNamedMultiColumnPrimaryKeyExpression()
{
var expression = new CreateTableExpression { TableName = TestTableName1 };
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, IsPrimaryKey = true, PrimaryKeyName = "TestKey", Type = DbType.String });
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32, IsPrimaryKey = true });
return expression;
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs
示例9: GetCreateTableWithDefaultValue
public static CreateTableExpression GetCreateTableWithDefaultValue()
{
CreateTableExpression expression = new CreateTableExpression() { TableName = TestTableName1, };
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, Type = DbType.String, DefaultValue = "Default", TableName = TestTableName1 });
expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32, DefaultValue = 0, TableName = TestTableName1 });
return expression;
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs
示例10: GetCreateTableExpression
private CreateTableExpression GetCreateTableExpression(string tableName)
{
var columnName1 = "ColumnName1";
var column1 = new ColumnDefinition { Name = columnName1, Type = DbType.String };
var expression = new CreateTableExpression { TableName = tableName };
expression.Columns.Add(column1);
return expression;
}
开发者ID:gliljas,项目名称:fluentmigrator,代码行数:10,代码来源:SqlServer2008GeneratorTests.cs
示例11: CreateTableMigration
public dynamic CreateTableMigration(CreateTableMigration createTableMigration)
{
var create_table_expr = new CreateTableExpression
{
TableName = createTableMigration.TableName,
SchemaName = createTableMigration.SchemaName,
};
create_table_expr.Columns = createTableMigration.Colunns.Select(build_column_definition).ToList();
return create_table_expr;
}
开发者ID:jcteague,项目名称:SchemaMigrator,代码行数:11,代码来源:FluentMigratorMigrationFactory.cs
示例12: CanCreateTableWithDateTimeOffsetColumn
public void CanCreateTableWithDateTimeOffsetColumn()
{
var expression = new CreateTableExpression {TableName = "TestTable1"};
expression.Columns.Add(new ColumnDefinition {TableName = "TestTable1", Name = "TestColumn1", Type = DbType.DateTimeOffset});
expression.Columns.Add(new ColumnDefinition {TableName = "TestTable1", Name = "TestColumn2", Type = DbType.DateTime2});
expression.Columns.Add(new ColumnDefinition {TableName = "TestTable1", Name = "TestColumn3", Type = DbType.Date});
expression.Columns.Add(new ColumnDefinition { TableName = "TestTable1", Name = "TestColumn4", Type = DbType.Time });
var result = Generator.Generate(expression);
result.ShouldBe("CREATE TABLE [dbo].[TestTable1] ([TestColumn1] DATETIMEOFFSET NOT NULL, [TestColumn2] DATETIME2 NOT NULL, [TestColumn3] DATE NOT NULL, [TestColumn4] TIME NOT NULL)");
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:11,代码来源:SqlServer2008GeneratorTests.cs
示例13: Generate
public override string Generate(CreateTableExpression expression)
{
string FederatedOn = "";
if (!(string.IsNullOrEmpty(expression.Federation.DistributionName) || string.IsNullOrEmpty(expression.FederationColumn)))
{
FederatedOn = string.Format(FederateTable, expression.Federation.DistributionName,
expression.FederationColumn);
}
return Wrap(string.Format("{0} {1}", base.Generate(expression), FederatedOn));
}
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:11,代码来源:AzureGenerator.cs
示例14: Generate
public override string Generate(CreateTableExpression expression)
{
var descriptionStatements = DescriptionGenerator.GenerateDescriptionStatements(expression);
var createTableStatement = string.Format("CREATE TABLE {0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), base.Generate(expression));
var descriptionStatementsArray = descriptionStatements as string[] ?? descriptionStatements.ToArray();
if (!descriptionStatementsArray.Any())
return createTableStatement;
return ComposeStatements(createTableStatement, descriptionStatementsArray);
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:11,代码来源:SqlServer2005Generator.cs
示例15: CanCreateTableExpression
public void CanCreateTableExpression()
{
CreateTableExpression expression = new CreateTableExpression { TableName = tableName };
expression.Columns.Add(column.Object);
using (command)
{
processor.Process(expression);
command.CommandText = string.Format("SELECT name FROM sqlite_master WHERE type='table' and name='{0}'", tableName);
command.ExecuteReader().Read().ShouldBeTrue();
}
}
开发者ID:ryaneastabrook,项目名称:fluentmigrator,代码行数:12,代码来源:SqliteProcessorTests.cs
示例16: Generate
/// <summary>
/// Outputs a create table string
/// </summary>
/// <param name="expression"></param>
/// <returns></returns>
public override string Generate(CreateTableExpression expression)
{
if (string.IsNullOrEmpty(expression.TableName)) throw new ArgumentNullException("expression", "expression.TableName cannot be empty");
if (expression.Columns.Count == 0) throw new ArgumentException("You must specifiy at least one column");
string quotedTableName = Quoter.QuoteTableName(expression.TableName);
string errors = ValidateAdditionalFeatureCompatibility(expression.Columns.SelectMany(x => x.AdditionalFeatures));
if (!string.IsNullOrEmpty(errors)) return errors;
return string.Format(CreateTable, quotedTableName, Column.Generate(expression.Columns, quotedTableName));
}
开发者ID:RenaldSB,项目名称:fluentmigrator,代码行数:17,代码来源:GenericGenerator.cs
示例17: CanCreateTableWithDateTimeOffsetColumn
public void CanCreateTableWithDateTimeOffsetColumn()
{
var tableName = "TestTable1";
var expression = new CreateTableExpression { TableName = tableName };
expression.Columns.Add(new ColumnDefinition { TableName = tableName, Name = "TestColumn1", Type = DbType.DateTimeOffset });
expression.Columns.Add(new ColumnDefinition { TableName = tableName, Name = "TestColumn2", Type = DbType.DateTime2 });
expression.Columns.Add(new ColumnDefinition { TableName = tableName, Name = "TestColumn3", Type = DbType.Date });
expression.Columns.Add(new ColumnDefinition { TableName = tableName, Name = "TestColumn4", Type = DbType.Time });
var result = Generator.Generate(expression);
result.ShouldBe(string.Format("CREATE TABLE \"public\".\"{0}\" (\"TestColumn1\" timestamptz NOT NULL, \"TestColumn2\" timestamp NOT NULL, \"TestColumn3\" date NOT NULL, \"TestColumn4\" time NOT NULL);", tableName));
}
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:12,代码来源:PostgresGeneratorTests.cs
示例18: Generate
public override string Generate(CreateTableExpression expression)
{
var createStatement = new StringBuilder();
var tableName = Quoter.QuoteTableName(expression.TableName);
createStatement.Append(string.Format("CREATE TABLE {0}.{1} ({2})", Quoter.QuoteSchemaName(expression.SchemaName), tableName, Column.Generate(expression.Columns, tableName)));
var descriptionStatement = DescriptionGenerator.GenerateDescriptionStatements(expression);
if (descriptionStatement != null && descriptionStatement.Any())
{
createStatement.Append(";");
createStatement.Append(string.Join(";", descriptionStatement.ToArray()));
}
return createStatement.ToString();
}
开发者ID:akema-fr,项目名称:fluentmigrator,代码行数:13,代码来源:PostgresGenerator.cs
示例19: CanMigrateTable
public void CanMigrateTable()
{
// Arrange
var create = new CreateTableExpression
{
TableName = "Foo"
,Columns = new List<ColumnDefinition> {new ColumnDefinition {Name = "Id", Type = DbType.Int32}}
};
var context = GetDefaultContext();
// Act
MigrateTable(context, create);
// Assert
context.MigrationIndex.ShouldBe(1);
}
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:16,代码来源:SqlServerMigrationTests.cs
示例20: CanReadLongViewDefinition
public void CanReadLongViewDefinition()
{
// Arrange
var create = new CreateTableExpression
{
TableName = "Foo",
Columns =
new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32 } }
};
IList<ViewDefinition> views;
var createSql = new StringBuilder();
createSql.Append("CREATE VIEW FooView As SELECT Id,");
createSql.Append("'");
createSql.Append(new string('A', 3000));
createSql.Append("'");
createSql.Append(" As LongText1,");
createSql.Append("'");
createSql.Append(new string('B', 3000));
createSql.Append("'");
createSql.Append(" As LongText2");
createSql.Append(" FROM Foo");
// Act
using (var connection = new SqlConnection(ConnectionString))
{
var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());
processor.Process(create);
Assert.IsTrue(processor.TableExists(string.Empty, create.TableName), "SqlServer");
processor.Execute(createSql.ToString());
var dumper = new SqlServerSchemaDumper(processor, new DebugAnnouncer());
views = dumper.ReadViewSchema();
processor.CommitTransaction();
}
// Assert
Assert.AreEqual(1, views.Count);
}
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:45,代码来源:SchemaDumpViewTests.cs
注:本文中的FluentMigrator.Expressions.CreateTableExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论