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; }
public DbTransactionScope(DbConnectionScope dbConnectionScope, System.Transactions.IsolationLevel isolationLevel, int timeoutInSeconds = 30) : this(isolationLevel, timeoutInSeconds) { AddConnectionScopeEnlistment(dbConnectionScope, false); }