本文整理汇总了C#中FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor.RollbackTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# SqlServerProcessor.RollbackTransaction方法的具体用法?C# SqlServerProcessor.RollbackTransaction怎么用?C# SqlServerProcessor.RollbackTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor
的用法示例。
在下文中一共展示了SqlServerProcessor.RollbackTransaction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteWithSqlServer
protected static void ExecuteWithSqlServer(Action<IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions)
{
if (!serverOptions.IsEnabled)
return;
var connection = new SqlConnection(serverOptions.ConnectionString);
var processor = new SqlServerProcessor(connection, new SqlServer2000Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions());
test(processor);
if (!processor.WasCommitted)
{
processor.RollbackTransaction();
}
}
示例2: CleanupTestSqlServerDatabase
private static void CleanupTestSqlServerDatabase(SqlConnection connection, SqlServerProcessor origProcessor)
{
if (origProcessor.WasCommitted)
{
connection.Close();
var cleanupProcessor = new SqlServerProcessor(connection, new SqlServer2008Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions(), new SqlServerDbFactory());
MigrationRunner cleanupRunner = SetupMigrationRunner(cleanupProcessor);
cleanupRunner.RollbackToVersion(0);
}
else
{
origProcessor.RollbackTransaction();
}
}
示例3: CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges
public void CallingProcessWithPerformDBOperationExpressionWhenInPreviewOnlyModeWillNotMakeDbChanges()
{
var output = new StringWriter();
var connection = new SqlConnection(IntegrationTestOptions.SqlServer2012.ConnectionString);
var processor = new SqlServerProcessor(
connection,
new SqlServer2012Generator(),
new TextWriterAnnouncer(output),
new ProcessorOptions { PreviewOnly = true },
new SqlServerDbFactory());
bool tableExists;
try
{
var expression =
new PerformDBOperationExpression
{
Operation = (con, trans) =>
{
var command = con.CreateCommand();
command.CommandText = "CREATE TABLE ProcessTestTable (test int NULL) ";
command.Transaction = trans;
command.ExecuteNonQuery();
}
};
processor.Process(expression);
tableExists = processor.TableExists("", "ProcessTestTable");
}
finally
{
processor.RollbackTransaction();
}
tableExists.ShouldBeFalse();
string fmOutput = output.ToString();
Assert.That(fmOutput, Is.StringContaining("/* Beginning Transaction */"));
Assert.That(fmOutput, Is.StringContaining("/* Performing DB Operation */"));
Assert.That(fmOutput, Is.StringContaining("/* Rolling back transaction */"));
}
示例4: ExecuteWithSqlServer
private static void ExecuteWithSqlServer(IntegrationTestOptions.DatabaseServerOptions serverOptions, TextWriterAnnouncer announcer, SqlServer2005Generator generator, Action<IMigrationProcessor> test, bool tryRollback)
{
using (var connection = new SqlConnection(serverOptions.ConnectionString))
{
var processor = new SqlServerProcessor(connection, generator, announcer, new ProcessorOptions(), new SqlServerDbFactory());
test(processor);
if (tryRollback && !processor.WasCommitted)
{
processor.RollbackTransaction();
}
}
}
示例5: ExecuteWithSqlServer
protected static void ExecuteWithSqlServer(Action<IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions, Boolean tryRollback)
{
if (!serverOptions.IsEnabled)
return;
var announcer = new TextWriterAnnouncer(System.Console.Out);
announcer.Heading("Testing Migration against MS SQL Server");
using (var connection = new SqlConnection(serverOptions.ConnectionString))
{
var processor = new SqlServerProcessor(connection, new SqlServer2000Generator(), announcer, new ProcessorOptions());
test(processor);
if (tryRollback && !processor.WasCommitted)
{
processor.RollbackTransaction();
}
}
}