本文整理汇总了C#中IProvider.DropColumn方法的典型用法代码示例。如果您正苦于以下问题:C# IProvider.DropColumn方法的具体用法?C# IProvider.DropColumn怎么用?C# IProvider.DropColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProvider
的用法示例。
在下文中一共展示了IProvider.DropColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToSql
public IEnumerable<string> ToSql(IProvider provider, IMigrationContext context)
{
AlterTableCommand parentAlterTableCommand;
AlterSchemaCommand parentAlterSchemaCommand;
AlterColumnCommand parentAlterColumnCommand;
AlterPrimaryKeyCommand parentAlterPrimaryKeyCommand;
AlterIndexCommand parentAlterIndexCommand;
AlterUniqueConstraintCommand parentAlterUniqueConstraintCommand;
AlterForeignKeyCommand parentAlterForeignKeyCommand;
if ((parentAlterTableCommand = Parent as AlterTableCommand) != null)
{
return provider.DropTable(new TableName(parentAlterTableCommand.TableName, parentAlterTableCommand.Schema ?? context.GetDefaultSchema()), Check == Check.IfExists);
}
else if ((parentAlterSchemaCommand = Parent as AlterSchemaCommand) != null)
{
return provider.DropSchema(parentAlterSchemaCommand.Schema);
}
else if ((parentAlterColumnCommand = Parent as AlterColumnCommand) != null)
{
return provider.DropColumn(new TableName(parentAlterColumnCommand.Parent.TableName, parentAlterColumnCommand.Parent.Schema ?? context.GetDefaultSchema()), parentAlterColumnCommand.ColumnName);
}
else if ((parentAlterPrimaryKeyCommand = Parent as AlterPrimaryKeyCommand) != null)
{
string effectiveConstraintName = DefaultObjectNameProvider.GetPrimaryKeyConstraintName(parentAlterPrimaryKeyCommand.Parent.TableName, parentAlterPrimaryKeyCommand.ConstraintName);
return provider.DropPrimaryKey(new TableName(parentAlterPrimaryKeyCommand.Parent.TableName, parentAlterPrimaryKeyCommand.Parent.Schema ?? context.GetDefaultSchema()), effectiveConstraintName);
}
else if ((parentAlterIndexCommand = Parent as AlterIndexCommand) != null)
{
return provider.DropIndex(new TableName(parentAlterIndexCommand.Parent.TableName, parentAlterIndexCommand.Parent.Schema ?? context.GetDefaultSchema()), parentAlterIndexCommand.IndexName);
}
else if ((parentAlterUniqueConstraintCommand = Parent as AlterUniqueConstraintCommand) != null)
{
return provider.DropUniqueConstraint(new TableName(parentAlterUniqueConstraintCommand.Parent.TableName, parentAlterUniqueConstraintCommand.Parent.Schema ?? context.GetDefaultSchema()), parentAlterUniqueConstraintCommand.ConstraintName);
}
else if ((parentAlterForeignKeyCommand = Parent as AlterForeignKeyCommand) != null)
{
return provider.DropForeignKey(new TableName(parentAlterForeignKeyCommand.Parent.TableName, parentAlterForeignKeyCommand.Parent.Schema ?? context.GetDefaultSchema()), parentAlterForeignKeyCommand.ConstraintName);
}
else
{
throw new InvalidOperationException("Unsupported parent command of a DropCommand.");
}
}
示例2: ToSql
public IEnumerable<string> ToSql(IProvider provider, IRuntimeContext context)
{
AlterTableCommand parentAlterTableCommand;
AlterColumnCommand parentAlterColumnCommand;
AlterPrimaryKeyCommand parentAlterPrimaryKeyCommand;
AlterIndexCommand parentAlterIndexCommand;
AlterUniqueConstraintCommand parentAlterUniqueConstraintCommand;
AlterForeignKeyCommand parentAlterForeignKeyCommand;
if ((parentAlterTableCommand = Parent as AlterTableCommand) != null)
{
return provider.DropTable(parentAlterTableCommand.TableName);
}
else if ((parentAlterColumnCommand = Parent as AlterColumnCommand) != null)
{
return provider.DropColumn(parentAlterColumnCommand.Parent.TableName, parentAlterColumnCommand.ColumnName);
}
else if ((parentAlterPrimaryKeyCommand = Parent as AlterPrimaryKeyCommand) != null)
{
string effectiveConstraintName = DefaultObjectNameProvider.GetPrimaryKeyConstraintName(parentAlterPrimaryKeyCommand.Parent.TableName, parentAlterPrimaryKeyCommand.ConstraintName);
return provider.DropPrimaryKey(parentAlterPrimaryKeyCommand.Parent.TableName, effectiveConstraintName);
}
else if ((parentAlterIndexCommand = Parent as AlterIndexCommand) != null)
{
return provider.DropIndex(parentAlterIndexCommand.Parent.TableName, parentAlterIndexCommand.IndexName);
}
else if ((parentAlterUniqueConstraintCommand = Parent as AlterUniqueConstraintCommand) != null)
{
return provider.DropUniqueConstraint(parentAlterUniqueConstraintCommand.Parent.TableName, parentAlterUniqueConstraintCommand.ConstraintName);
}
else if ((parentAlterForeignKeyCommand = Parent as AlterForeignKeyCommand) != null)
{
return provider.DropForeignKey(parentAlterForeignKeyCommand.Parent.TableName, parentAlterForeignKeyCommand.ConstraintName);
}
else
{
throw new InvalidOperationException("Unsupported parent command of a DropCommand.");
}
}