public SqliteDataComponentFactory(RetryOptions retryOptions, string connectionString) : base()
        {
            _connectionFactory =
                String.IsNullOrEmpty(connectionString) ?
                new SqliteConnectionFactoryWithRetry(retryOptions) :
                new SqliteConnectionFactoryWithRetry(retryOptions, connectionString);

            _transactionFactory = new SqliteTransactionFactoryWithRetry(retryOptions);
            _dataAdapterFactory = new SqliteDataAdapterFactory();
            _parameterFactory   = new SqliteParameterFactory();
        }
Пример #2
0
        public SqliteDataComponentFactory(SqliteTransientRetryPolicy retryPolicy, IConnectionStringFactory connectionStringFactory) : base()
        {
            _connectionFactory =
                connectionStringFactory == null ?
                new SqliteConnectionFactoryWithRetry(retryPolicy) :
                new SqliteConnectionFactoryWithRetry(retryPolicy, connectionStringFactory);

            _transactionFactory = new SqliteTransactionFactoryWithRetry(retryPolicy);
            _dataAdapterFactory = new SqliteDataAdapterFactory();
            _parameterFactory   = new SqliteParameterFactory();
        }
Пример #3
0
        public SqliteDataComponentFactory(SqliteTransientRetryPolicy retryPolicy, string connectionString) : base()
        {
            _connectionFactory =
                string.IsNullOrEmpty(connectionString) ?
                new SqliteConnectionFactoryWithRetry(retryPolicy) :
                new SqliteConnectionFactoryWithRetry(retryPolicy, connectionString);

            _transactionFactory = new SqliteTransactionFactoryWithRetry(retryPolicy);
            _dataAdapterFactory = new SqliteDataAdapterFactory();
            _parameterFactory   = new SqliteParameterFactory();
        }
        public void BeginTransaction_WithRetry()
        {
            var retryOptions = new RetryOptions(10, TimeSpan.FromSeconds(60));

            ITransactionFactory transactionFactory = new SqliteTransactionFactoryWithRetry(retryOptions);
            IConnectionFactory  connectionFactory  = new SqliteConnectionFactoryWithRetry(retryOptions);

            using (var connection = connectionFactory.Open(_connectionString))
                using (var transaction = transactionFactory.BeginTransaction(connection))
                {
                    Assert.IsNotNull(transaction);
                    Assert.AreEqual(connection, transaction.Connection);
                    Assert.AreEqual(IsolationLevel.Serializable, transaction.IsolationLevel);
                    transaction.Rollback();
                }
        }
        public void BeginTransaction_WithIsolationLevel_WithRetry_Fail()
        {
            // sqlite only supports IsolationLevel.Serializable
            var retryPolicy = new SqliteTransientRetryPolicy(10, TimeSpan.FromSeconds(60));

            ITransactionFactory transactionFactory = new SqliteTransactionFactoryWithRetry(retryPolicy);
            IConnectionFactory  connectionFactory  = new SqliteConnectionFactoryWithRetry(retryPolicy);

            using (var connection = connectionFactory.Open(_connectionString))
                using (var transaction = transactionFactory.BeginTransaction(connection, IsolationLevel.Snapshot))
                {
                    Assert.IsNotNull(transaction);
                    Assert.AreEqual(connection, transaction.Connection);
                    Assert.AreEqual(IsolationLevel.Snapshot, transaction.IsolationLevel);
                    transaction.Rollback();
                }
        }