本文整理汇总了C#中IMigrationContext类的典型用法代码示例。如果您正苦于以下问题:C# IMigrationContext类的具体用法?C# IMigrationContext怎么用?C# IMigrationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMigrationContext类属于命名空间,在下文中一共展示了IMigrationContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SchemaIndexQuery
public SchemaIndexQuery(string schemaName, string tableName, string indexName, IMigrationContext context)
{
_schemaName = schemaName;
_tableName = tableName;
_indexName = indexName;
_context = context;
}
开发者ID:timscott,项目名称:fluentmigrator,代码行数:7,代码来源:SchemaIndexQuery.cs
示例2: GetMigrationInstance
public static Migration GetMigrationInstance(
this Assembly assembly,
IMigrationContext migrationContext)
{
return (Migration) assembly.GetTypeInstance(DefaultMigrationName,
migrationContext);
}
开发者ID:joelabrahamsson,项目名称:Page-Type-Builder,代码行数:7,代码来源:TypeGenerationExtensions.cs
示例3: IfDatabaseExpressionRoot
/// <summary>
/// Constricts a new instance of a <see cref="IfDatabaseExpressionRoot"/> that will only add expressions to the provided <see cref="context"/> if <see cref="databaseType"/> matches the migration processor
/// </summary>
/// <remarks>If the database type does not apply then a <seealso cref="NullIfDatabaseProcessor"/> will be used as a container to void any fluent expressions that would have been executed</remarks>
/// <param name="context">The context to add expressions to if the database type applies</param>
/// <param name="databaseType">The database type that the expressions relate to</param>
public IfDatabaseExpressionRoot(IMigrationContext context, params string[] databaseType)
{
if (databaseType == null) throw new ArgumentNullException("databaseType");
_origContext = context;
_databaseType = databaseType;
_context = DatabaseTypeApplies(context, databaseType) ? context : new MigrationContext(new MigrationConventions(), new NullIfDatabaseProcessor(), context.MigrationAssembly, context.ApplicationContext);
}
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:13,代码来源:IfDatabaseExpressionRoot.cs
示例4: PageTypeAction
public PageTypeAction(
IPageType pageType,
IMigrationContext context)
{
this.pageType = pageType;
this.context = context;
}
开发者ID:joelabrahamsson,项目名称:Page-Type-Builder,代码行数:7,代码来源:PageTypeAction.cs
示例5: ForEachFederationExpressionBuilder
public ForEachFederationExpressionBuilder(IMigrationContext context, ForEachFederationExpression expression)
{
_expression = expression;
expression.Context = new MigrationContext (context.Conventions, context.QuerySchema,
context.MigrationAssembly,
context.ApplicationContext);
}
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:7,代码来源:ForEachFederationExpressionBuilder.cs
示例6: SchemaColumnQuery
public SchemaColumnQuery(string schemaName, string tableName, string columnName, IMigrationContext context)
{
_schemaName = schemaName;
_tableName = tableName;
_columnName = columnName;
_context = context;
}
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:SchemaColumnQuery.cs
示例7: GetUpExpressions
public virtual void GetUpExpressions(IMigrationContext context)
{
lock (_mutex)
{
_context = context;
Up();
_context = null;
}
}
开发者ID:shawng,项目名称:fluentmigrator,代码行数:9,代码来源:Migration.cs
示例8: ToSql
public IEnumerable<string> ToSql(IProvider provider, IMigrationContext context)
{
if (_columnNames.Count == 0)
{
throw new InvalidCommandException("At least one column must be added to the AddForeignKeyTo command.");
}
string effectiveConstraintName = GetEffectiveConstraintName();
return provider.AddForeignKey(new TableName(Parent.TableName, Parent.Schema ?? context.GetDefaultSchema()), new TableName(_referencedTableName, ReferencedTableSchema ?? Parent.Schema ?? context.GetDefaultSchema()), _columnNames.Select(p => new ColumnReference(p.Key, p.Value)), effectiveConstraintName, CascadeOnDelete);
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:9,代码来源:AddForeignKeyToCommand.cs
示例9: ToSql
public IEnumerable<string> ToSql(IProvider provider, IMigrationContext context)
{
if (_columnNames.Count == 0)
{
throw new InvalidCommandException("At least one column must be added to the AddIndex command.");
}
string effectiveIndexName = GetEffectiveIndexName();
return provider.AddIndex(new TableName(Parent.TableName, Parent.Schema ?? context.GetDefaultSchema()), _columnNames, effectiveIndexName);
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:9,代码来源:AddIndexCommand.cs
示例10: ToSql
public IEnumerable<string> ToSql(IProvider provider, IMigrationContext context)
{
var runtimeContext = context as IRuntimeContext;
if (runtimeContext != null) // the runtimeContext == null, when recording the changes to the RecordingProvider for validation
{
Log.Verbose(LogCategory.Sql, "Performing call-back");
_action(runtimeContext);
}
yield break;
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:10,代码来源:CallCommand.cs
示例11: GetDownExpressions
public virtual void GetDownExpressions(IMigrationContext context)
{
lock (_lock)
{
ApplicationContext = context.ApplicationContext;
Database = new TransformationProvider(context);
Down();
Database = null;
}
}
开发者ID:tgmayfield,项目名称:fluentmigrator.legacy.migratordotnet,代码行数:10,代码来源:MigratorDotNetMigration.cs
示例12: GetDownExpressions
public virtual void GetDownExpressions(IMigrationContext context)
{
lock (_mutex)
{
_context = context;
ApplicationContext = context.ApplicationContext;
Down();
_context = null;
}
}
开发者ID:rebootd,项目名称:fluentmigrator,代码行数:10,代码来源:MigrationBase.cs
示例13: MigrateTask
/// <summary>
/// Circumvents actual SQL task migration code and records its "execution" to the test migration
/// context. It allows the actual execution of .NET code patches.
/// </summary>
/// <param name="context">the migration context</param>
/// <param name="task">the task to migrate</param>
public override void MigrateTask(IMigrationContext context, IMigrationTask task)
{
if (task is SqlScriptMigrationTask)
{
((TestMigrationContext)context).RecordExecution(task.Name);
}
else
{
base.MigrateTask(context, task);
}
}
开发者ID:easel,项目名称:autopatch,代码行数:17,代码来源:FakeSqlMigrationProcess.cs
示例14: GetUpExpressions
public virtual void GetUpExpressions(IMigrationContext context)
{
lock (_mutex)
{
_context = context;
ApplicationContext = context.ApplicationContext;
ConnectionString = context.Connection;
Up();
_context = null;
}
}
开发者ID:BhuvanB,项目名称:fluentmigrator,代码行数:11,代码来源:MigrationBase.cs
示例15: Migrate
public override void Migrate(IMigrationContext context)
{
if (!ForceFail)
{
TestMigrationContext ctx = (TestMigrationContext)context;
ctx.RecordExecution(Name);
}
else
{
throw new MigrationException("Something went wrong running '" + Name + "'");
}
}
开发者ID:easel,项目名称:autopatch,代码行数:12,代码来源:MigrationTask2.cs
示例16: GetDatabaseContainingMigrationChanges
protected Database GetDatabaseContainingMigrationChanges(MigrationDirection direction, IMigrationContext context)
{
var database = new Database(context);
if (direction == MigrationDirection.Up)
{
_migration.Up(database);
}
else
{
Debug.Assert(direction == MigrationDirection.Down);
var migration = _migration as IReversibleMigration;
if (migration == null)
{
throw new InvalidOperationException("Cannot downgrade an irreversible migration."); // this should never happen
}
migration.Down(database);
}
return database;
}
开发者ID:Kareo,项目名称:MigSharp,代码行数:19,代码来源:BootstrapMigrationStep.cs
示例17: 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.");
}
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:43,代码来源:DropCommand.cs
示例18: Create
public static MigrationReport Create(Database database, string migrationName, IMigrationContext context)
{
// execute changes in 'database' against a RecordingProvider
var recordingProvider = new RecordingProvider();
var translator = new CommandsToSqlTranslator(recordingProvider);
string error = string.Empty;
try
{
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
translator.TranslateToSql(database, context).ToList(); // .ToList() is important to effectively trigger the iteration
// ReSharper restore ReturnValueOfPureMethodIsNotUsed
}
catch (InvalidCommandException x)
{
error = x.Message;
}
// create MigrationReport
return new MigrationReport(migrationName, error, recordingProvider);
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:20,代码来源:MigrationReport.cs
示例19: ToSql
public IEnumerable<string> ToSql(IProvider provider, IMigrationContext context)
{
if (IsNullable && DefaultValue != null)
{
throw new InvalidCommandException("Adding nullable columns with default values is not supported: some database platforms (like SQL Server) leave missing values NULL and some update missing values to the default value. Consider adding the column first as not-nullable, and then altering it to nullable.");
}
TableName tableName = new TableName(Parent.TableName, Parent.Schema ?? context.GetDefaultSchema());
var dataType = new DataType(Type, Size, Scale);
var column = new Column(ColumnName, dataType, IsNullable, DefaultValue, IsRowVersion);
IEnumerable<string> commands = provider.AddColumn(tableName, column);
if (DropThereafter)
{
commands = commands.Concat(provider.DropDefault(tableName, new Column(
column.Name,
column.DataType,
column.IsNullable,
null, false)));
}
return commands;
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:20,代码来源:AddColumnCommand.cs
示例20: ToSql
public IEnumerable<string> ToSql(IProvider provider, IMigrationContext context)
{
string effectivePkConstraintName = GetEffectivePkConstraintName();
List<CreateColumnCommand> createColumnCommands = GetCreateColumnCommands().ToList();
if (createColumnCommands.Count == 0)
{
throw new InvalidCommandException("At least one column must be added to the CreateTable command.");
}
return provider.CreateTable(
new TableName(TableName, Schema ?? context.GetDefaultSchema()),
createColumnCommands.Select(c => new CreatedColumn(
c.ColumnName,
new DataType(c.Type, c.Size, c.Scale),
c.IsNullable,
c.IsPrimaryKey,
GetEffectiveUniqueConstraintName(c),
c.IsIdentity,
c.DefaultValue,
c.IsRowVersion)),
effectivePkConstraintName);
}
开发者ID:dradovic,项目名称:MigSharp,代码行数:21,代码来源:CreateTableCommand.cs
注:本文中的IMigrationContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论