Exemplo n.º 1
0
        private void AddConnectionScopeEnlistment(DbConnectionScope scope, bool createdByTransaction)
        {
            var connectionOpenedByTransaction = false;

            if (scope.Connection.State == System.Data.ConnectionState.Closed)
            {
                scope.Connection.Open();
                connectionOpenedByTransaction = true;
            }

            scope.Connection.EnlistTransaction(_transaction);

            var enlistment = new DbConnectionScopeEnlistment()
            {
                Scope = scope,
                ConnectionOpenedByTransaction = connectionOpenedByTransaction,
                CreatedByTransaction          = createdByTransaction,
            };
            var type = scope.GetType();

            _dbConnectionScopeCache[type] = enlistment;
        }
Exemplo n.º 2
0
 public DbTransactionScope(DbConnectionScope dbConnectionScope, System.Transactions.IsolationLevel isolationLevel, int timeoutInSeconds = 30)
     : this(isolationLevel, timeoutInSeconds)
 {
     AddConnectionScopeEnlistment(dbConnectionScope, false);
 }