private IDbConnection GetConnection()
        {
            IDbConnection connection;

            if (ScopeIsActive)
            {
                var transaction = ThreadStorage.GetData <IDbTransaction>(TransactionScope.ScopeTransactionKey);

                if (transaction != null)
                {
                    connection = transaction.Connection;
                }
                else
                {
                    connection = this.GetDbConnection();

                    connection.Open();

                    transaction = connection.BeginTransaction();
                    ThreadStorage.SetData(TransactionScope.ScopeTransactionKey, transaction);
                }
            }
            else
            {
                connection = this.GetDbConnection();

                connection.Open();
            }

            return(connection);
        }
Exemple #2
0
 public TransactionScope()
 {
     ThreadStorage.SetData(ActiveScopeKey, true);
 }