/// <summary>
        /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer <ISagaStorage> configurer,
                                            string connectionStringOrConnectionStringName, string dataTableName, string indexTableName,
                                            bool automaticallyCreateTables = true)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }
            if (connectionStringOrConnectionStringName == null)
            {
                throw new ArgumentNullException(nameof(connectionStringOrConnectionStringName));
            }
            if (dataTableName == null)
            {
                throw new ArgumentNullException(nameof(dataTableName));
            }
            if (indexTableName == null)
            {
                throw new ArgumentNullException(nameof(indexTableName));
            }

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get <IRebusLoggerFactory>();
                var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory);
                var sagaStorage        = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory);

                if (automaticallyCreateTables)
                {
                    sagaStorage.EnsureTablesAreCreated();
                }

                return(sagaStorage);
            });
        }
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);
            _connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            _dataTableName = TestConfig.QueueName("sagas");
            _indexTableName = TestConfig.QueueName("sagaindex");

            SqlTestHelper.DropTable(_indexTableName);
            SqlTestHelper.DropTable(_dataTableName);

            _storage = new SqlServerSagaStorage(_connectionProvider, _dataTableName, _indexTableName, loggerFactory);
        }
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);
            var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory);

            var dataTableName = TestConfig.QueueName("sagas");
            var indexTableName = TestConfig.QueueName("sagaindex");

            SqlTestHelper.DropTable(indexTableName);
            SqlTestHelper.DropTable(dataTableName);

            _storage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, loggerFactory);

            _storage.EnsureTablesAreCreated();
        }
        /// <summary>
        /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer <ISagaStorage> configurer,
                                            string connectionStringOrConnectionStringName, string dataTableName, string indexTableName,
                                            bool automaticallyCreateTables = true)
        {
            configurer.Register(c =>
            {
                var sagaStorage = new SqlServerSagaStorage(
                    new DbConnectionProvider(connectionStringOrConnectionStringName),
                    dataTableName, indexTableName);

                if (automaticallyCreateTables)
                {
                    sagaStorage.EnsureTablesAreCreated();
                }

                return(sagaStorage);
            });
        }
        /// <summary>
        /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer<ISagaStorage> configurer,
            string connectionStringOrConnectionStringName, string dataTableName, string indexTableName,
            bool automaticallyCreateTables = true)
        {
            configurer.Register(c =>
            {
                var sagaStorage = new SqlServerSagaStorage(
                    new DbConnectionProvider(connectionStringOrConnectionStringName),
                    dataTableName, indexTableName);

                if (automaticallyCreateTables)
                {
                    sagaStorage.EnsureTablesAreCreated();
                }

                return sagaStorage;
            });
        }
        /// <summary>
        /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer<ISagaStorage> configurer,
            string connectionStringOrConnectionStringName, string dataTableName, string indexTableName,
            bool automaticallyCreateTables = true)
        {
            if (configurer == null) throw new ArgumentNullException(nameof(configurer));
            if (connectionStringOrConnectionStringName == null) throw new ArgumentNullException(nameof(connectionStringOrConnectionStringName));
            if (dataTableName == null) throw new ArgumentNullException(nameof(dataTableName));
            if (indexTableName == null) throw new ArgumentNullException(nameof(indexTableName));

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get<IRebusLoggerFactory>();
                var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory);
                var sagaStorage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory);

                if (automaticallyCreateTables)
                {
                    sagaStorage.EnsureTablesAreCreated();
                }

                return sagaStorage;
            });
        }