当前位置: 首页>>代码示例>>C#>>正文


C# SqlServerProcessor.RollbackTransaction方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:nats,项目名称:fluentmigrator,代码行数:14,代码来源:IntegrationTestBase.cs

示例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();
            }
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:16,代码来源:MigrationRunnerTests.cs

示例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 */"));
        }
开发者ID:tgmayfield,项目名称:fluentmigrator,代码行数:47,代码来源:SqlServerProcessorTests.cs

示例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();
                }
            }
        }
开发者ID:rebootd,项目名称:fluentmigrator,代码行数:13,代码来源:IntegrationTestBase.cs

示例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();
                }
            }
        }
开发者ID:ryaneastabrook,项目名称:fluentmigrator,代码行数:19,代码来源:IntegrationTestBase.cs


注:本文中的FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor.RollbackTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。