Load() public method

public Load ( IDbConnection connection, IDbTransaction transaction ) : void
connection IDbConnection
transaction IDbTransaction
return void
Example #1
0
        private PersistedVersioning GetPersistedVersioning(IDbConnection connection, IDbTransaction transaction, IDbCommandExecutor executor)
        {
            if (_persistedVersioning == null)
            {
                var history = new History(_versioningTableName, _providerMetadata);
                if (!_versioningTableExists.Value)
                {
                    Debug.Assert(connection != null, "At this point, an upgrade of the versioning table is requested. This always takes part of a running migration step and therefore already has an associated connection (and possibly a transaction).");

                    // execute the boostrap migration to create the versioning table
                    var step = new BootstrapMigrationStep(new BootstrapMigration(_versioningTableName), _provider, _providerMetadata);
                    step.Execute(connection, transaction, MigrationDirection.Up, executor);
                    _versioningTableExists = new Lazy <bool>(() => true); // now, the versioning table exists
                }
                else
                {
                    // load the existing entries from the versioning table
                    IDbConnection c = connection ?? _connectionFactory.OpenConnection(_connectionInfo);
                    try
                    {
                        history.Load(c, transaction);
                    }
                    finally
                    {
                        if (connection == null) // we had to open a connection ourselves
                        {
                            c.Dispose();
                        }
                    }
                }
                _persistedVersioning = new PersistedVersioning(history);
            }
            Debug.Assert(_persistedVersioning != null);
            return(_persistedVersioning);
        }
 public SqlAggregateMigrationGenerator(Server server, Database database, GeneratorOptions options)
     : base(server, database, options)
 {
     var providerLocator = new ProviderLocator(new ProviderFactory()); // CLEAN: use DI container
     ProviderInfo provider = providerLocator.GetExactly(DbPlatform.SqlServer2008);
     var versioningTableName = new TableName(options.VersioningTableName, options.VersioningTableSchema);
     _history = new History(versioningTableName, provider.Metadata);
     IDbConnection connection = server.ConnectionContext.SqlConnectionObject;
     connection.Open();
     connection.ChangeDatabase(Database.Name); // ATTENTION: possibly has side-effects
     try
     {
         _history.Load(connection, null);
     }
     finally
     {
         connection.Close();
     }
 }
Example #3
0
        private PersistedVersioning GetPersistedVersioning(IDbConnection connection, IDbTransaction transaction, IDbCommandExecutor executor)
        {
            if (_persistedVersioning == null)
            {
                var history = new History(_versioningTableName, _configuration.ProviderInfo.Metadata);
                if (!_versioningTableExists.Value)
                {
                    Debug.Assert(connection != null, "At this point, an upgrade of the versioning table is requested. This always takes part of a running migration step and therefore already has an associated connection (and possibly a transaction).");

                    // execute the boostrap migration to create the versioning table
                    var step = new BootstrapMigrationStep(new BootstrapMigration(_versioningTableName), null);
                    step.Execute(_configuration.ProviderInfo, connection, transaction, MigrationDirection.Up, executor);
                    _versioningTableExists = new Lazy<bool>(() => true); // now, the versioning table exists
                }
                else
                {
                    // load the existing entries from the versioning table
                    IDbConnection c = connection ?? _configuration.OpenConnection();
                    try
                    {
                        history.Load(c, transaction);
                    }
                    finally
                    {
                        if (connection == null) // we had to open a connection ourselves
                        {
                            c.Dispose();
                        }
                    }
                }
                _persistedVersioning = new PersistedVersioning(history);
            }
            Debug.Assert(_persistedVersioning != null);
            return _persistedVersioning;
        }