internal DACScope(IDAC dac, ScopeContextPolicy policy, bool openConnection, string contextPrefix = DefaultContextPrefix, Auto?autoAction = null) : base(string.Format(ContextNameTemplate, contextPrefix, dac.ConnectionString), policy) { if (dac == null) { throw new ArgumentNullException("dac"); } DAC = dac; if (IsRootScope) { _connection = new RestrictedConnection(DAC.CreateConnection()); if (openConnection) { _connection.Open(); } _scopeOwnsConnection = true; _transaction = null; _scopeOwnsTransaction = false; _transactionOwner = null; } else { if (RootScope._connection == null) { throw new SoftwareException("Internal Error: RootScope DAC had null connection"); } _connection = RootScope._connection; _transaction = RootScope._transaction; _transactionOwner = RootScope._transactionOwner; _scopeOwnsTransaction = false; _scopeOwnsConnection = false; if (openConnection && _connection.State.IsIn(ConnectionState.Closed, ConnectionState.Broken)) { _connection.Open(); } } _withinSystemTransactionScope = System.Transactions.Transaction.Current != null; if (_scopeOwnsConnection && _withinSystemTransactionScope) { DAC.EnlistInSystemTransaction(_connection.DangerousInternalConnection, System.Transactions.Transaction.Current); } _voteRollback = false; _scopeHasOpenTransaction = false; _autoAction = autoAction; }
public virtual void EnlistInSystemTransaction(IDbConnection connection, System.Transactions.Transaction transaction) { DecoratedDAC.EnlistInSystemTransaction(connection, transaction); }