public DataTransaction BeginTransaction(DataTransactionIsolation isolation = DataTransactionIsolation.ReadCommitted) { DataTransaction transaction = null; // ReSharper disable once AccessToModifiedClosure transaction = new DataTransaction(mConnection, () => PopTransaction(transaction), isolation); mTransaction.Push(transaction); return(transaction); }
private void PopTransaction(DataTransaction transaction) { if (mTransaction.Count == 0) { return; } var current = mTransaction.Pop(); if (current == null) { return; } if (!ReferenceEquals(current, transaction)) { throw new InvalidOperationException("Invalid transaction exit order. When cascading transactions, the inner transactions have to be closed before the outer transactions."); } }