Exemple #1
0
 public override void Create()
 {
     using (var masterConnection = _connection.CreateMasterConnection())
     {
         _statementExecutor.ExecuteNonQuery(masterConnection, CreateCreateOperations());
         ClearPool();
     }
 }
Exemple #2
0
 public override void Create()
 {
     Console.WriteLine("CREATE " +);
     using (var masterConnection = _connection.CreateMasterConnection())
     {
         _statementExecutor.ExecuteNonQuery(masterConnection, null, CreateCreateOperations());
         ClearPool();
     }
 }
Exemple #3
0
        public override void Create()
        {
            using (var masterConnection = _connection.CreateMasterConnection())
            {
                _statementExecutor.ExecuteNonQuery(masterConnection, null, CreateCreateOperations());
                ClearPool();
            }

            Exists(retryOnNotExists: true);
        }
Exemple #4
0
        public override void Delete()
        {
            ClearAllPools();

            using (var masterConnection = _connection.CreateMasterConnection())
            {
                SqlStatementExecutor
                .ExecuteNonQuery(masterConnection, CreateDropCommands());
            }
        }
        public override void CreateTables(IModel model)
        {
            Check.NotNull(model, "model");

            var operations = _modelDiffer.DiffSource(model);
            var statements = _generator.Generate(operations, generateIdempotentSql: false);

            // TODO: Delete database on error
            using (var connection = _connection.CreateConnectionReadWrite())
            {
                _executor.ExecuteNonQuery(connection, statements);
            }
        }
        public override void CreateTables(IModel model)
        {
            Check.NotNull(model, "model");

            var generator  = _generatorFactory.Create();
            var operations = _modelDiffer.CreateSchema(model);
            var statements = generator.Generate(operations);

            // TODO: Delete database on error
            using (var connection = _connection.CreateConnectionReadWrite())
            {
                _executor.ExecuteNonQuery(connection, null, statements);
            }
        }
Exemple #7
0
        protected virtual void Execute([NotNull] IEnumerable <SqlBatch> sqlBatches, bool ensureDatabase = false)
        {
            Check.NotNull(sqlBatches, nameof(sqlBatches));

            if (ensureDatabase && !_dataStoreCreator.Exists())
            {
                _dataStoreCreator.Create();
            }

            using (var transaction = _connection.BeginTransaction())
            {
                _executor.ExecuteNonQuery(_connection, transaction.DbTransaction, sqlBatches);
                transaction.Commit();
            }
        }
Exemple #8
0
        public override void CreateTables(IModel model)
        {
            Check.NotNull(model, "model");

            // TODO: SQLiteMigrationOperationSqlGenerator should get this from DI
            _generator.Database = _modelDiffer.DatabaseBuilder.GetDatabase(model);
            var operations = _modelDiffer.CreateSchema(model);
            var statements = _generator.Generate(operations);

            // TODO: Delete database on error
            using (var connection = _connection.CreateConnectionReadWrite())
            {
                _executor.ExecuteNonQuery(connection, null, statements);
            }
        }
        private static void CreateDatabaseSequence(BronieContext context, DataStoreConnection storeConnection)
        {
            var executor = new SqlStatementExecutor();

            var operations = new SqlServerSequenceValueGeneratorFactory(executor)
                             .GetUpMigrationOperations(context.Model.GetEntityType(typeof(Pegasus))
                                                       .GetProperty("Identifier"));

            var sql = new SqlServerMigrationOperationSqlGenerator(new SqlServerTypeMapper())
                      .Generate(operations, generateIdempotentSql: false);

            // TODO: Should be able to get relational connection without cast
            var connection = ((RelationalConnection)storeConnection).DbConnection;

            executor.ExecuteNonQuery(connection, sql);
        }