本文整理汇总了C#中FluentMigrator.Expressions.CreateColumnExpression类的典型用法代码示例。如果您正苦于以下问题:C# CreateColumnExpression类的具体用法?C# CreateColumnExpression怎么用?C# CreateColumnExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateColumnExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了CreateColumnExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public override string Generate(CreateColumnExpression expression)
{
string errors = ValidateAdditionalFeatureCompatibility(expression.Column.AdditionalFeatures);
if (!string.IsNullOrEmpty(errors)) return errors;
return String.Format(AddColumn, Quoter.QuoteTableName(expression.TableName), Column.Generate(expression.Column));
}
示例2: ReverseSetsTableNameAndColumnNameOnGeneratedExpression
public void ReverseSetsTableNameAndColumnNameOnGeneratedExpression()
{
var expression = new CreateColumnExpression { TableName = "Bacon", Column = { Name = "BaconId" } };
var reverse = expression.Reverse() as DeleteColumnExpression;
reverse.TableName.ShouldBe("Bacon");
reverse.ColumnName.ShouldBe("BaconId");
}
示例3: CanUseSystemMethodCurrentDateTimeAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentDateTimeAsADefaultValueForAColumn()
{
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 15, Type = null, CustomType = "TIMESTAMP", DefaultValue = SystemMethods.CurrentDateTime };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = "NewTable" };
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE `NewTable` ADD COLUMN `NewColumn` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP");
}
示例4: CanAddColumnWithGetDateDefault
public void CanAddColumnWithGetDateDefault()
{
ColumnDefinition column = new ColumnDefinition { Name = "TestColumn1", Type = DbType.String,
Size = 5, DefaultValue = "GetDate()" };
var expression = new CreateColumnExpression { TableName = "TestTable1", Column = column };
var sql = _generator.Generate(expression);
sql.ShouldBe("ALTER TABLE [TestTable1] ADD [TestColumn1] NVARCHAR(5) NOT NULL DEFAULT GetDate()");
}
示例5: CreateColumnGenerator
public dynamic CreateColumnGenerator(CreateColumnMigration createColumnMigration)
{
var column_migration_expr = new CreateColumnExpression
{
Column = build_column_definition(createColumnMigration)
};
return column_migration_expr;
}
示例6: CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 5, Type = DbType.String, DefaultValue = SystemMethods.CurrentUTCDateTime };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE NewTable ADD COLUMN NewColumn VARGRAPHIC(5) CCSID 1200 NOT NULL DEFAULT (CURRENT_TIMESTAMP - CURRENT_TIMEZONE)");
}
示例7: CanUseSystemMethodCurrentUserAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentUserAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 18, Type = DbType.AnsiString, DefaultValue = SystemMethods.CurrentUser };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE NewTable ADD COLUMN NewColumn VARCHAR(18) NOT NULL DEFAULT USER");
}
示例8: CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 5, Type = DbType.String, DefaultValue = SystemMethods.CurrentUTCDateTime };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE \"public\".\"NewTable\" ADD \"NewColumn\" varchar(5) NOT NULL DEFAULT (now() at time zone 'UTC')");
}
示例9: CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 5, Type = DbType.String, DefaultValue = SystemMethods.CurrentUTCDateTime };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE \"NewTable\" ADD (\"NewColumn\" NVARCHAR(5) DEFAULT CURRENT_UTCTIMESTAMP);");
}
示例10: CanAddDecimalColumn
public void CanAddDecimalColumn()
{
var tableName = "NewTable";
var columnDefinition = new ColumnDefinition {Name = "NewColumn", Size = 19, Precision = 2, Type = DbType.Decimal};
var expression = new CreateColumnExpression {Column = columnDefinition, TableName = tableName};
ApplyDefaultConventions(expression);
var sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE [NewTable] ADD COLUMN NewColumn NUMERIC NOT NULL");
}
示例11: CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Type = DbType.DateTime, DefaultValue = SystemMethods.CurrentUTCDateTime };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };
string sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE [dbo].[NewTable] ADD [NewColumn] DATETIME NOT NULL CONSTRAINT DF__NewColumn DEFAULT GETUTCDATE()");
}
示例12: CanUseSystemMethodCurrentUserAsADefaultValueForAColumn
public void CanUseSystemMethodCurrentUserAsADefaultValueForAColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 15, Type = DbType.String, DefaultValue = SystemMethods.CurrentUser };
var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };
string sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE [dbo].[NewTable] ADD [NewColumn] NVARCHAR(15) NOT NULL CONSTRAINT DF__NewColumn DEFAULT CURRENT_USER");
}
示例13: Generate
public override string Generate(CreateColumnExpression expression)
{
var createStatement = new StringBuilder();
createStatement.Append(string.Format("ALTER TABLE {0}.{1} ADD {2}", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteTableName(expression.TableName), Column.Generate(expression.Column)));
var descriptionStatement = DescriptionGenerator.GenerateDescriptionStatement(expression);
if (!string.IsNullOrEmpty(descriptionStatement))
{
createStatement.Append(";");
createStatement.Append(descriptionStatement);
}
return createStatement.ToString();
}
示例14: CanAddDecimalColumn
public void CanAddDecimalColumn()
{
const string tableName = "NewTable";
var columnDefinition = new ColumnDefinition();
columnDefinition.Name = "NewColumn";
columnDefinition.Size = 19;
columnDefinition.Precision = 2;
columnDefinition.Type = DbType.Decimal;
var expression = new CreateColumnExpression {Column = columnDefinition, TableName = tableName};
string sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE \"public\".\"NewTable\" ADD \"NewColumn\" decimal(19,2) NOT NULL");
}
示例15: CanAddIdentityColumn
public void CanAddIdentityColumn()
{
string tableName = "NewTable";
var columnDefinition = new ColumnDefinition();
columnDefinition.Name = "id";
columnDefinition.IsIdentity=true;
columnDefinition.Type = DbType.Int32;
var expression = new CreateColumnExpression();
expression.Column = columnDefinition;
expression.TableName = tableName;
string sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE \"public\".\"NewTable\" ADD \"id\" serial NOT NULL");
}