public DataAccessScope(DataAccessIsolationLevel isolationLevel, DataAccessScopeOptions options, TimeSpan timeout) { this.IsolationLevel = isolationLevel; var currentTransaction = DataAccessTransaction.Current; this.options = options; switch (options) { case DataAccessScopeOptions.Required: if (currentTransaction == null) { this.isRoot = true; this.transaction = new DataAccessTransaction(isolationLevel, timeout); DataAccessTransaction.Current = this.transaction; } else { this.transaction = currentTransaction; this.outerTransaction = currentTransaction; } break; case DataAccessScopeOptions.RequiresNew: this.isRoot = true; this.outerTransaction = currentTransaction; if (Transaction.Current != null) { this.nativeScope = new TransactionScope(TransactionScopeOption.RequiresNew); } this.transaction = new DataAccessTransaction(isolationLevel, timeout); DataAccessTransaction.Current = this.transaction; break; case DataAccessScopeOptions.Suppress: if (Transaction.Current != null) { this.nativeScope = new TransactionScope(TransactionScopeOption.Suppress); } if (currentTransaction != null) { this.outerTransaction = currentTransaction; DataAccessTransaction.Current = null; } break; } }
public DataAccessScope(DataAccessScopeOptions options) : this(DataAccessIsolationLevel.Unspecified, options, TimeSpan.Zero) { }
public DataAccessScope(DataAccessScopeOptions options) : this(DataAccessIsolationLevel.Unspecified, options, TimeSpan.Zero) { }
public DataAccessScope(DataAccessIsolationLevel isolationLevel, DataAccessScopeOptions options, TimeSpan timeout) { this.IsolationLevel = isolationLevel; var currentTransaction = DataAccessTransaction.Current; this.options = options; switch (options) { case DataAccessScopeOptions.Required: if (currentTransaction == null) { this.isRoot = true; this.transaction = new DataAccessTransaction(isolationLevel, timeout); DataAccessTransaction.Current = this.transaction; } else { this.transaction = currentTransaction; this.outerTransaction = currentTransaction; } break; case DataAccessScopeOptions.RequiresNew: this.isRoot = true; this.outerTransaction = currentTransaction; if (Transaction.Current != null) { this.nativeScope = new TransactionScope(TransactionScopeOption.RequiresNew); } this.transaction = new DataAccessTransaction(isolationLevel, timeout); DataAccessTransaction.Current = this.transaction; break; case DataAccessScopeOptions.Suppress: if (Transaction.Current != null) { this.nativeScope = new TransactionScope(TransactionScopeOption.Suppress); } if (currentTransaction != null) { this.outerTransaction = currentTransaction; DataAccessTransaction.Current = null; } break; } }