本文整理汇总了C#中FluentMigrator.Expressions.AlterColumnExpression类的典型用法代码示例。如果您正苦于以下问题:C# AlterColumnExpression类的具体用法?C# AlterColumnExpression怎么用?C# AlterColumnExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AlterColumnExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了AlterColumnExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanAlterColumn
public void CanAlterColumn()
{
var expression = new AlterColumnExpression
{
Column = new ColumnDefinition { Type = DbType.String, Name = "Col1" },
SchemaName = "Schema1",
TableName = "Table1"
};
var sql = generator.Generate(expression);
sql.ShouldBe(String.Empty);
}
示例2: Generate
public override string Generate(AlterColumnExpression expression)
{
var alterStatement = new StringBuilder();
alterStatement.Append(String.Format("ALTER TABLE {0}.{1} {2}", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteTableName(expression.TableName), ((PostgresColumn)Column).GenerateAlterClauses(expression.Column)));
var descriptionStatement = DescriptionGenerator.GenerateDescriptionStatement(expression);
if (!string.IsNullOrEmpty(descriptionStatement))
{
alterStatement.Append(";");
alterStatement.Append(descriptionStatement);
}
return alterStatement.ToString();
}
示例3: GetAlterColumnExpression
public static AlterColumnExpression GetAlterColumnExpression()
{
var expression = new AlterColumnExpression();
expression.TableName = TestTableName1;
expression.Column = new ColumnDefinition();
expression.Column.Name = TestColumnName1;
expression.Column.Type = DbType.String;
expression.Column.Size = 20;
expression.Column.IsNullable = false;
return expression;
}
示例4: GenerateDescriptionStatement
public override string GenerateDescriptionStatement(AlterColumnExpression expression)
{
if (string.IsNullOrEmpty(expression.Column.ColumnDescription))
return string.Empty;
var formattedSchemaName = FormatSchemaName(expression.SchemaName);
// For this, we need to remove the extended property first if exists (or implement verification and use sp_updateextendedproperty)
var columnVerificationStatement = string.Format(ColumnDescriptionVerificationTemplate, formattedSchemaName, expression.TableName, expression.Column.Name);
var removalStatement = string.Format("{0} {1}", columnVerificationStatement, GenerateColumnDescriptionRemoval(formattedSchemaName, expression.TableName, expression.Column.Name));
var newDescriptionStatement = GenerateColumnDescription(formattedSchemaName, expression.TableName, expression.Column.Name, expression.Column.ColumnDescription);
return string.Join(";", new[] { removalStatement, newDescriptionStatement });
}
示例5: Process
public override void Process(AlterColumnExpression expression)
{
var tableDefinition = GetTableSchema(expression.TableName);
var columnDefinitions = tableDefinition.Columns.ToList();
var columnIndex = columnDefinitions.FindIndex(c => c.Name == expression.Column.Name);
if (columnIndex == -1)
{
throw new ApplicationException(string.Format("Column {0} does not exist on table {1}.", expression.Column.Name, expression.TableName));
}
columnDefinitions[columnIndex] = expression.Column;
tableDefinition.Columns = columnDefinitions;
ProcessAlterTable(tableDefinition);
}
示例6: Process
public virtual void Process(AlterColumnExpression expression)
{
Process(Generator.Generate(expression));
}
示例7: Generate
public override string Generate(AlterColumnExpression expression)
{
return string.Format("ALTER TABLE {0}", base.Generate(expression));
}
示例8: Truncate
public void Truncate(AlterColumnExpression expression)
{
expression.TableName = Truncate(expression.TableName);
Truncate(expression.Column);
}
示例9: CanAlterColumn
public void CanAlterColumn()
{
var expression = new AlterColumnExpression
{
Column = new ColumnDefinition {Type = DbType.String, Name = "Col1"},
SchemaName = "Schema1",
TableName = "Table1"
};
var sql = generator.Generate(expression);
sql.ShouldBe("ALTER TABLE \"Schema1\".\"Table1\" ALTER \"Col1\" TYPE text");
}
示例10: ToStringIsDescriptive
public void ToStringIsDescriptive()
{
var expression = new AlterColumnExpression { TableName = "Bacon", Column = { Name = "BaconId", Type = DbType.Int32 } };
expression.ToString().ShouldBe("AlterColumn Bacon BaconId Int32");
}
示例11: Generate
public override string Generate(AlterColumnExpression expression)
{
var descriptionStatement = DescriptionGenerator.GenerateDescriptionStatement(expression);
if (string.IsNullOrEmpty(descriptionStatement))
return base.Generate(expression);
var wrappedAlterColumnStatement = WrapStatementInExecuteImmediateBlock(base.Generate(expression));
var alterColumnWithDescriptionBuilder = new StringBuilder(wrappedAlterColumnStatement);
alterColumnWithDescriptionBuilder.Append(WrapStatementInExecuteImmediateBlock(descriptionStatement));
return WrapInBlock(alterColumnWithDescriptionBuilder.ToString());
}
示例12: Generate
public override string Generate(AlterColumnExpression expression)
{
throw new NotImplementedException();
}
示例13: CanAlterColumnAndSetAsNullable
public void CanAlterColumnAndSetAsNullable()
{
var expression = new AlterColumnExpression
{
Column = new ColumnDefinition { Type = DbType.String, Name = "TestColumn1", IsNullable = true },
SchemaName = "TestSchema",
TableName = "TestTable1"
};
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE \"TestSchema\".\"TestTable1\" ALTER \"TestColumn1\" TYPE text, ALTER \"TestColumn1\" DROP NOT NULL");
}
示例14: Generate
public override string Generate(AlterColumnExpression expression)
{
return compatabilityMode.HandleCompatabilty("Sqlite does not support alter column");
}
示例15: CanAlterColumnAndSetAsNullable
public void CanAlterColumnAndSetAsNullable()
{
var expression = new AlterColumnExpression
{
Column = new ColumnDefinition { Type = DbType.String, Name = "TestColumn1", IsNullable = true },
SchemaName = "TestSchema",
TableName = "TestTable1"
};
var result = Generator.Generate(expression);
result.ShouldBe("ALTER TABLE TestSchema.TestTable1 ALTER COLUMN TestColumn1 SET DATA TYPE DBCLOB(1048576) CCSID 1200");
}