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


C# Migrator类代码示例

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


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


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