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

C# Migrator类代码示例

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

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



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

示例1: SetUpCurrentVersion

		void SetUpCurrentVersion(long version, List<long> appliedVersions, bool assertRollbackIsCalled, bool includeBad)
		{
			var providerMock = new DynamicMock(typeof (ITransformationProvider));

			providerMock.SetReturnValue("get_MaxVersion", version);
			providerMock.SetReturnValue("get_AppliedMigrations", appliedVersions);
			providerMock.SetReturnValue("get_Logger", new Logger(false));
			if (assertRollbackIsCalled)
				providerMock.Expect("Rollback");
			else
				providerMock.ExpectNoCall("Rollback");

			_migrator = new Migrator((ITransformationProvider) providerMock.MockInstance, Assembly.GetExecutingAssembly(), false);

			// Enlève toutes les migrations trouvée automatiquement
			_migrator.MigrationsTypes.Clear();
			_upCalled.Clear();
			_downCalled.Clear();

			_migrator.MigrationsTypes.Add(typeof (FirstMigration));
			_migrator.MigrationsTypes.Add(typeof (SecondMigration));
			_migrator.MigrationsTypes.Add(typeof (ThirdMigration));
			_migrator.MigrationsTypes.Add(typeof (FourthMigration));
			_migrator.MigrationsTypes.Add(typeof (SixthMigration));

			if (includeBad)
				_migrator.MigrationsTypes.Add(typeof (BadMigration));
		}
开发者ID:CALUMO,项目名称:Migrator.NET,代码行数:28,代码来源:MigratorTestDates.cs


示例2: Execute

        public override bool Execute()
        {
            using (var store = new DocumentStore())
            {
                store.ConfigureUsingConnectionString(ConnectionString);
                store.Initialize();

                var migrator = new Migrator();
                foreach (var item in Migrations)
                {
                    var assembly = Assembly.LoadFrom(item.GetMetadata("FullPath"));
                    migrator.Migrate(store, assembly, ToVersion);
                }
            }

            if (ToVersion > 0)
            {
                Log.LogMessage("Migrated to version " + ToVersion + ".");
            }
            else
            {
                Log.LogMessage("Migrated to maximum version.");
            }
            return true;
        }
开发者ID:andrewdavey,项目名称:ravendb-migrations,代码行数:25,代码来源:Migrate.cs


示例3: Migrate

 public bool Migrate(string connectionString, string providerName, IEnumerable<Type> entities, Action<MigratorResult, Type> callbackOnChanges)
 {
     var bResult = false;
     var provider = ProviderFactory.GetProvider(connectionString, providerName);
     foreach (var entity in entities)
     {
         var batch = new BatchQuery(provider);
         var m = new Migrator(Assembly.GetExecutingAssembly());
         var commands = m.MigrateFromModel(entity, provider);
         bResult |= commands.Length > 0;
         try
         {
             foreach (var s in commands)
                 batch.QueueForTransaction(new QueryCommand(PrepareCommand(s), provider));
             batch.ExecuteTransaction();
         }
         catch(Exception ex)
         {
             var sb = new StringBuilder(ex.Message);
             sb.Append(": ");
             foreach (var command in commands)
                 sb.Append(command);
             throw new Exception(sb.ToString(), ex);
         }
         if (callbackOnChanges == null) continue;
         callbackOnChanges(commands.Length > 0 ? MigratorResult.ChangesMadeToEntity : MigratorResult.NoChanges,
                           entity);
     }
     if (callbackOnChanges != null)
         callbackOnChanges(MigratorResult.ChangesMadeToAllEntities, null);
     return bResult;
 }
开发者ID:acropolium,项目名称:AcroDB,代码行数:32,代码来源:SubSonicMigrationProvider.cs


示例4: Get

        public ActionResult Get(string id)
        {
            var migrator = new Migrator(RavenSessionManager.DocumentStore, typeof(MigrationClass).Assembly);
            var status = migrator.GetMigrationStatus();

            return View(status);
        }
开发者ID:newaccount978,项目名称:CommonJobs,代码行数:7,代码来源:MigrationsController.cs


示例5: Create

        public static Migrator Create(string targetName, Migrator migrator)
        {
            migrator.Guard = new Guard();

            switch (targetName)
            {
                case "mysql":
                    migrator.DbInterface = new DbInterface();
                    migrator.DbInterface.Executor = new Executor();
                    migrator.Applier = new MySQL.Applier();
                    break;
                case "mssql":
                    migrator.DbInterface = new MSSQL.DbInterface();
                    migrator.DbInterface.Executor = new MSSQL.Executor();
                    migrator.Applier = new MSSQL.Applier();
                    break;
                case "postgresql":
                    migrator.DbInterface = new PostgreSQL.DbInterface();
                    migrator.DbInterface.Executor = new PostgreSQL.Executor();
                    migrator.Applier = new PostgreSQL.Applier();
                    break;
                default:
                    throw new Exception("Target name " + targetName + " is not valid");
            }

            return migrator;
        }
开发者ID:prunkster,项目名称:db-migrator-net,代码行数:27,代码来源:Factory.cs


示例6: SetUp

		public void SetUp()
		{			
            _migrator = new Migrator(TransformationProvider, MigrationAssembly, true);
			
			Assert.IsTrue(_migrator.MigrationsTypes.Count > 0, "No migrations in assembly " + MigrationAssembly.Location);
			
			_migrator.MigrateTo(0);
		}
开发者ID:jango2015,项目名称:Migrator.NET,代码行数:8,代码来源:MigrationTestCase.cs


示例7: SetUp

        public void SetUp()
        {
            _migrator = new Migrator(TransformationProvider);

            Assert.IsTrue(_migrator.MigrationsTypes.Count > 0);

            _migrator.MigrateTo(0);
        }
开发者ID:kayone,项目名称:Migrator.NET,代码行数:8,代码来源:MigrationTestCase.cs


示例8: Execute

    public override bool Execute()
    {
      log4net.Config.BasicConfigurator.Configure(new Log4NetMsBuildAppender(this.Log, new log4net.Layout.PatternLayout("%-5p %x %m")));
      var migrator = new Migrator();
      migrator.Run(this);

      return true;
    }
开发者ID:emmekappa,项目名称:machine.migrations,代码行数:8,代码来源:MigratorTask.cs


示例9: GetMigrator

        private Migrator GetMigrator()
        {
            Assembly asm = Assembly.LoadFrom(ConfigurationManager.AppSettings["MigrationAsembly"]);
            string provider = ConfigurationManager.AppSettings["MigrationProvider"];
            string connectString = ConfigurationManager.AppSettings["ConnectionString"];

            Migrator migrator = new Migrator(provider, connectString, asm, false);
            return migrator;
        }
开发者ID:IntranetFactory,项目名称:migratordotnet,代码行数:9,代码来源:Default.aspx.cs


示例10: TestIrreversibleMigrationExceptionIsThrown

        public void TestIrreversibleMigrationExceptionIsThrown()
        {
            long timestamp2 = typeof(Migration2).GetTimestamp();
            IVersioning versioning = GetVersioning(true, true, true);

            Migrator migrator = new Migrator("", ProviderNames.SqlServer2008);
            migrator.UseCustomVersioning(versioning);
            migrator.FetchMigrationsTo(typeof(Migration1).Assembly, timestamp2); // should throw an IrreversibleMigrationException as Migration3 is irreversible
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:9,代码来源:MigratorTests.cs


示例11: Execute_WithSingleValue_TakesValue

        public void Execute_WithSingleValue_TakesValue()
        {
            var migrator = new Migrator();

            string json = @"{execute: 'SELECT current_timestamp' }";

            string command = migrator.GetCommandFromJson(json);

            Assert.AreEqual("SELECT current_timestamp", command);
        }
开发者ID:thomasvm,项目名称:ManateeCommand,代码行数:10,代码来源:ExecuteTests.cs


示例12: Can_Export_Database_Into_Export_File

        public void Can_Export_Database_Into_Export_File()
        {
            var migrator = new Migrator();
            migrator.Migrate();

            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, BlogMLExportWorker.ExportFileName);
            var exportFile = new FileInfo(path);

            Assert.True(exportFile.Exists);
        }
开发者ID:HEskandari,项目名称:OxiteMigrator,代码行数:10,代码来源:MigratorFacts.cs


示例13: VerifyPendingMigrationsAreFoundForSpecificModule

        public void VerifyPendingMigrationsAreFoundForSpecificModule()
        {
            IVersioning versioning = GetVersioning(false, false, false);

            Migrator migrator = new Migrator("", ProviderNames.SqlServer2008, new MigrationOptions { ModuleSelector = m => m == Migration2.Module });
            migrator.UseCustomVersioning(versioning);
            IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly);

            Assert.AreEqual(1, batch.Count, string.Format(CultureInfo.CurrentCulture, "Only one migration for the module named '{0}' exists.", Migration2.Module));
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:10,代码来源:MigratorTests.cs


示例14: CreateDatabase

 public static void CreateDatabase(string dbName, string relativePath)
 {
     string dbFilePath = GetAbsoluteDatabaseFilePath(dbName, relativePath);
     string connectionString = ConnectionString(dbFilePath);
     Migrator migrator = new Migrator(connectionString);
     #if DEBUG
     migrator.Migrate(runner => runner.MigrateDown(0));
     #endif
     migrator.Migrate(runner => runner.MigrateUp());
     DapperExtensions.DapperExtensions.DefaultMapper = typeof(PluralizedAutoClassMapper<>);
 }
开发者ID:4201715125,项目名称:S4201715125V1,代码行数:11,代码来源:RepositoryBase.cs


示例15: VerifyPendingMigrationsAreFound

        public int VerifyPendingMigrationsAreFound(bool migration1IsContained, bool migration2IsContained, bool migration3IsContained)
        {
            IVersioning versioning = GetVersioning(migration1IsContained, migration2IsContained, migration3IsContained);

            Migrator migrator = new Migrator("", ProviderNames.SqlServer2008);
            migrator.UseCustomVersioning(versioning);
            IMigrationBatch batch = migrator.FetchMigrations(typeof(Migration1).Assembly);

            versioning.VerifyAllExpectations();
            return batch.Count;
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:11,代码来源:MigratorTests.cs


示例16: create_database_and_apply_all_migrations

        public void create_database_and_apply_all_migrations()
        {
            Mock<ISupplyMigrations> source = SetupSource();

            Mock<ICommandDatabases> handler = SetupHandler(new DatabaseVersion {Type = DatabaseVersionType.NotCreated});
            Mock<ICompareMigrations> comparer = SetupComparer();
            var migrator = new Migrator(source.Object, comparer.Object, handler.Object);
            migrator.Migrate();
            handler.Verify(h => h.Create(), Times.Once);
            handler.Verify(h => h.CreateMigrationHistoryTable(), Times.Never);
            handler.Verify(h => h.ExecuteMigration(It.IsAny<Migration>()), Times.Exactly(2));
        }
开发者ID:pperboires,项目名称:SqlMigrator,代码行数:12,代码来源:MigratorFacts.cs


示例17: GetMigrationsList

 private List<MigrationInfo> GetMigrationsList(Migrator mig)
 {
     List<System.Type> migrations = mig.MigrationsTypes;
     migrations.Reverse();
     List<MigrationInfo> list = new List<MigrationInfo>();
     List<System.Type>.Enumerator en = migrations.GetEnumerator();
     while(en.MoveNext()){
         MigrationInfo info = new MigrationInfo(en.Current);
         list.Add(info);
     }
     return list;
 }
开发者ID:IntranetFactory,项目名称:migratordotnet,代码行数:12,代码来源:Default.aspx.cs


示例18: Program

        public Program(IApplicationEnvironment appEnv, ILoggerProvider logProvider)
        {
            _logger = logProvider?.CreateLogger(this.GetType().ToString()) ?? new ConsoleLogger(this.GetType().ToString(), (catgory,level) => { return true; }, true);

            Configuration =
                new ConfigurationBuilder()
                .SetBasePath(appEnv.ApplicationBasePath)
                .AddJsonFile("config.json", true)
                .Build();

            _migrator = new Migrator(Configuration, appEnv.ApplicationName);
        }
开发者ID:staff0rd,项目名称:entityframework-migrations,代码行数:12,代码来源:Program.cs


示例19: CanMoveDownWithoutTransaction

        public void CanMoveDownWithoutTransaction()
        {
            var provider = new Mock<ITransformationProvider>();
            Assembly asm = Assembly.Load("ECM7.Migrator.TestAssembly");

            using (var migrator = new Migrator(provider.Object, asm))
            {
                migrator.ExecuteMigration(4, 4);

                provider.Verify(db => db.ExecuteNonQuery("down4"));
                provider.Verify(db => db.MigrationUnApplied(4, "test-key111"));
            }
        }
开发者ID:svn2github,项目名称:ecm7migrator,代码行数:13,代码来源:ExecuteMigrationTest.cs


示例20: Execute_WithArray_ConcatenesValues

        public void Execute_WithArray_ConcatenesValues()
        {
            var migrator = new Migrator();

            string json = @"{execute: [
                                'SELECT current_timestamp, ',
                                'system_user'
                            ]}";

            string command = migrator.GetCommandFromJson(json);

            Assert.AreEqual(string.Format(@"SELECT current_timestamp, {0}system_user{0}", Environment.NewLine), command);
        }
开发者ID:thomasvm,项目名称:ManateeCommand,代码行数:13,代码来源:ExecuteTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# MimeEntity类代码示例发布时间:2022-05-24
下一篇:
C# MigrationConventions类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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