• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SqlServer.SqlServerProcessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessor的典型用法代码示例。如果您正苦于以下问题:C# SqlServerProcessor类的具体用法?C# SqlServerProcessor怎么用?C# SqlServerProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlServerProcessor类属于FluentMigrator.Runner.Processors.SqlServer命名空间,在下文中一共展示了SqlServerProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetUp

 public void SetUp()
 {
     Connection = new SqlConnection(IntegrationTestOptions.SqlServer2012.ConnectionString);
     Processor = new SqlServerProcessor(Connection, new SqlServer2012Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions(), new SqlServerDbFactory());
     Connection.Open();
     Processor.BeginTransaction();
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:SqlServerSequenceTests.cs


示例2: SqlServerProcessorTests

        public SqlServerProcessorTests()
        {
            Connection = new SqlConnection(@"server=(local)\sqlexpress;uid=;pwd=;Trusted_Connection=yes;database=FluentMigrator");
            Connection.Open();

            Processor = new SqlServerProcessor(Connection, new SqlServer2000Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions());
        }
开发者ID:paulbatum,项目名称:fluentmigrator,代码行数:7,代码来源:SqlServerProcessorTests.cs


示例3: ExecuteWithSqlServer

 public void ExecuteWithSqlServer(Action<IMigrationProcessor> test)
 {
     var connection = new SqlConnection(sqlServerConnectionString);
     connection.Open();
     var processor = new SqlServerProcessor(connection, new SqlServerGenerator());
     test(processor);
 }
开发者ID:stevehodgkiss,项目名称:fluentmigrator,代码行数:7,代码来源:IntegrationTestBase.cs


示例4: Run

        public static void Run(string connectionString)
        {
            var firstMigration = typeof(Lucid.Database.Migrations.Y2016.M01.V01);
            var assembly = new SingleAssembly(firstMigration.Assembly);

            var migrationGenerator = new SqlServer2008Generator();
            var announcer = new NullAnnouncer();
            var options = new ProcessorOptions();
            var dbFactory = new SqlServerDbFactory();

            var runnerContext = new RunnerContext(announcer)
            {
                Database = "SqlServer2008",
                Connection = connectionString,
                Targets = new string[] { firstMigration.Assembly.FullName },
                NestedNamespaces = true,
                Namespace = "Lucid.Database.Migrations",
            };

            using (var connection = new SqlConnection(connectionString))
            using (var processor = new SqlServerProcessor(connection, migrationGenerator, announcer, options, dbFactory))
            {
                var runner = new MigrationRunner(assembly, runnerContext, processor);

                runner.MigrateUp();
            }
        }
开发者ID:FlukeFan,项目名称:LucidDotNet,代码行数:27,代码来源:LucidMigrationRunner.cs


示例5: SqlServerProcessorTests

        public SqlServerProcessorTests()
        {
            Connection = new SqlConnection(@"server=(local)\sqlexpress;uid=;pwd=;Trusted_Connection=yes;database=FluentMigrator");
            Connection.Open();

            Processor = new SqlServerProcessor(Connection, new SqlServerGenerator());
        }
开发者ID:stevehodgkiss,项目名称:fluentmigrator,代码行数:7,代码来源:SqlServerProcessorTests.cs


示例6: Setup

 public void Setup()
 {
     Connection = new SqlConnection(IntegrationTestOptions.SqlServer2008.ConnectionString);
     Processor = new SqlServerProcessor(Connection, new SqlServer2008Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions(), new SqlServerDbFactory());
     SchemaDumper = new SqlServerSchemaDumper(Processor, new TextWriterAnnouncer(System.Console.Out));
     Connection.Open();
 }
开发者ID:abusby,项目名称:fluentmigrator,代码行数:7,代码来源:SchemaDumpTests.cs


示例7: SqlServerTestTable

        public SqlServerTestTable(SqlServerProcessor processor, params string[] columnDefinitions)
        {
            Connection = processor.Connection;
            Transaction = processor.Transaction;

            Name = "Table" + Guid.NewGuid().ToString("N");
            Create(columnDefinitions);
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:8,代码来源:SqlServerTestTable.cs


示例8: SqlServerTestSequence

        public SqlServerTestSequence(SqlServerProcessor processor, string schemaName, string sequenceName)
        {
            _schemaName = schemaName;
            Name = sequenceName;

            Connection = (SqlConnection)processor.Connection;
            Transaction = (SqlTransaction)processor.Transaction;
            Create();
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:9,代码来源:SqlServerTestSequence.cs


示例9: SqlServerTestTable

        public SqlServerTestTable(string table, SqlServerProcessor processor, string schemaName, params string[] columnDefinitions)
        {
            this.schemaName = schemaName;
            Connection = (SqlConnection)processor.Connection;
            Transaction = (SqlTransaction)processor.Transaction;

            Name = table;

            Create(columnDefinitions);
        }
开发者ID:patrickbird,项目名称:fluentmigrator,代码行数:10,代码来源:SqlServerTestTable.cs


示例10: ExecuteWithSqlServer

        private static void ExecuteWithSqlServer(Action<IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions)
        {
            if (!serverOptions.IsEnabled)
                return;

            var connection = new SqlConnection(serverOptions.ConnectionString);
            connection.Open();
            var processor = new SqlServerProcessor(connection, new SqlServer2000Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions());
            test(processor);
        }
开发者ID:Andrea,项目名称:fluentmigrator,代码行数:10,代码来源:IntegrationTestBase.cs


示例11: getRunner

        MigrationRunner getRunner()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["dahliaSQL"].ConnectionString;
            var connection = new SqlConnection(connectionString);
            var assembly = typeof(SqlMigrationService).Assembly;
            var ns = typeof(SqlMigrationService).Namespace;
            var generator = new SqlServer2005Generator();
            var processor = new SqlServerProcessor(connection, generator, new NullAnnouncer(), new ProcessorOptions());

            return new MigrationRunner(assembly, new RunnerContext(new NullAnnouncer()) { Namespace = ns },
                                          processor);
        }
开发者ID:olsonjeffery,项目名称:Dahlia,代码行数:12,代码来源:SqlMigrationRunner.cs


示例12: ExecuteWithSqlServer

        protected static void ExecuteWithSqlServer(Action<IMigrationProcessor> test, IntegrationTestOptions.DatabaseServerOptions serverOptions, Boolean tryRollback)
        {
            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 (tryRollback && !processor.WasCommitted)
            {
                processor.RollbackTransaction();
            }
        }
开发者ID:Ang3lFir3,项目名称:fluentmigrator,代码行数:14,代码来源:IntegrationTestBase.cs


示例13: CanApplyIndexConvention

        public void CanApplyIndexConvention()
        {
            var connection = new SqlConnection(sqlServerConnectionString);
             connection.Open();
             var processor = new SqlServerProcessor(connection, new SqlServerGenerator());

             var conventions = new MigrationConventions();
             var runner = new MigrationRunner(conventions, processor);

             runner.Up(new TestIndexNamingConvention());
             processor.TableExists("Users").ShouldBeTrue();

             runner.Down(new TestIndexNamingConvention());
             processor.TableExists("Users").ShouldBeFalse();
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:15,代码来源:MigrationRunnerTests.cs


示例14: EnsureMigration

        private void EnsureMigration()
        {
            var connection = new System.Data.SqlClient.SqlConnection(connectionString);
            connection.Open();
            var processor = new SqlServerProcessor(connection, new SqlServer2000Generator(),
                new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions());
            var conventions = new MigrationConventions();
            var versionRunner = new FluentMigrator.Runner.MigrationVersionRunner(conventions, processor,
                new MigrationLoader(conventions), new NullAnnouncer());
            //var runner = new MigrationRunner(conventions, processor, new TextWriterAnnouncer(System.Console.Out), new StopWatch());
            //runner.Up(new TestCreateAndDropTableMigration());
            versionRunner.MigrateUp();

            versionRunner = null;
            connection = null;
        }
开发者ID:rebootd,项目名称:NoSQLIntro1,代码行数:16,代码来源:TestBase.cs


示例15: CanApplyForeignKeyConvention

        public void CanApplyForeignKeyConvention()
        {
            var connection = new SqlConnection(sqlServerConnectionString);
            connection.Open();
            var processor = new SqlServerProcessor(connection, new SqlServerGenerator());

             var conventions = new MigrationConventions();
             var runner = new MigrationRunner(conventions, processor);

             runner.Up(new TestForeignKeyNamingConvention());
             processor.TableExists("Users").ShouldBeTrue();
             processor.ConstraintExists( "Users", "FK_Users_GroupId_Groups_GroupId").ShouldBeTrue();

             runner.Down(new TestForeignKeyNamingConvention());
             processor.TableExists("Users").ShouldBeFalse();
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:16,代码来源:MigrationRunnerTests.cs


示例16: Main

        public static void Main(string[] args)
        {
            var connection = new SqlConnection("data source=172.16.1.186;UID=lssuser;PWD=password1;initial catalog=lss");

            var sb = new StringBuilder();
            var textWriter = new StringWriter(sb);
            var announcer = new TextWriterAnnouncer(textWriter);

            var generator = new SqlServer2008Generator();
            var processor = new SqlServerProcessor(connection, generator, announcer, new ProcessorOptions(), new SqlServerDbFactory());

            var dumper = new SqlServerSchemaDumper(processor, announcer);

            var schema = dumper.ReadDbSchema();
            var schemaWriter = new SchemaWriter();
            schemaWriter.WriteToFile(schema, "C:\\migration.cs");
        }
开发者ID:francisspor,项目名称:SchemaDumper,代码行数:17,代码来源:Program.cs


示例17: CanReadLongViewDefinition

        public void CanReadLongViewDefinition()
        {
            // Arrange
             var create = new CreateTableExpression
             {
            TableName = "Foo",
            Columns =
               new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32 } }
             };

             IList<ViewDefinition> views;

             var createSql = new StringBuilder();
             createSql.Append("CREATE VIEW FooView As SELECT Id,");
             createSql.Append("'");
             createSql.Append(new string('A', 3000));
             createSql.Append("'");
             createSql.Append(" As LongText1,");
             createSql.Append("'");
             createSql.Append(new string('B', 3000));
             createSql.Append("'");
             createSql.Append(" As LongText2");
             createSql.Append(" FROM Foo");

             // Act
             using (var connection = new SqlConnection(ConnectionString))
             {
            var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());

            processor.Process(create);

            Assert.IsTrue(processor.TableExists(string.Empty, create.TableName), "SqlServer");

            processor.Execute(createSql.ToString());

            var dumper = new SqlServerSchemaDumper(processor, new DebugAnnouncer());
            views = dumper.ReadViewSchema();

            processor.CommitTransaction();
             }

             // Assert

             Assert.AreEqual(1, views.Count);
        }
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:45,代码来源:SchemaDumpViewTests.cs


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


示例19: CanReadMultipleViews

        public void CanReadMultipleViews()
        {
            // Arrange
             var create = new CreateTableExpression
             {
            TableName = "Foo",
            Columns =
               new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32 } }
             };

             IList<ViewDefinition> views;

             // Act
             using (var connection = new SqlConnection(ConnectionString))
             {
            var processor = new SqlServerProcessor(connection, new SqlServer2005Generator(), new DebugAnnouncer(), new ProcessorOptions());

            processor.Process(create);

            Assert.IsTrue(processor.TableExists(string.Empty, create.TableName), "SqlServer");

            processor.Execute("CREATE VIEW FooViewC AS SELECT Id FROM Foo");
            processor.Execute("CREATE VIEW FooViewB AS SELECT Id FROM Foo");
            processor.Execute("CREATE VIEW FooViewA AS SELECT Id FROM Foo");

            var dumper = new SqlServerSchemaDumper(processor, new DebugAnnouncer());
            views = dumper.ReadViewSchema();

            processor.CommitTransaction();
             }

             // Assert

             Assert.AreEqual(3, views.Count);

             Assert.AreEqual("FooViewA", views[0].Name);
             Assert.AreEqual("FooViewB", views[1].Name);
             Assert.AreEqual("FooViewC", views[2].Name);
        }
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:39,代码来源:SchemaDumpViewTests.cs


示例20: MigrateDown

        public static void MigrateDown(string connectionString, long version, Stream stream, bool previewOnly)
        {
            if (version == 0)
            {
                Console.WriteLine(string.Format("Purging Database"));
                Honcho.Migrations.DatabasePurge.Migrate.Execute(connectionString);
                Console.WriteLine(string.Format("Database Purge Complete"));
            }
            else
            {
                Console.WriteLine(string.Format("Executing Migration Rollback Scripts."));
                using (var connection = new SqlConnection(connectionString))
                {
                    IAnnouncer announcer = new NullAnnouncer(); // TextWriterAnnouncer(Console.Out);
                    var processorOptions = new ProcessorOptions
                                               {
                                                   PreviewOnly = previewOnly
                                               };

                    if (stream != null)
                    {
                        announcer = new TextWriterAnnouncer(new StreamWriter(stream));
                    }

                    var runnerContext = new RunnerContext(announcer);

                    var processor = new SqlServerProcessor(connection, new SqlServer2008Generator(), announcer,
                                                           processorOptions);
                    var runner = new MigrationRunner(Assembly.GetAssembly(typeof (Runner)), runnerContext,
                                                     processor);

                    runner.RollbackToVersion(version);
                }
                Console.WriteLine(string.Format("Migration Rollback Script Execution Complete"));
            }
        }
开发者ID:bgriswold,项目名称:Honcho,代码行数:36,代码来源:Runner.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Helpers.FirebirdTestTable类代码示例发布时间:2022-05-26
下一篇:
C# Initialization.RunnerContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap