예제 #1
0
        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);
        }
예제 #2
0
        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.");
            }
        }