예제 #1
0
        /// <inheritdoc />
        public virtual async Task CommitAsync(CancellationToken cancellationToken = default)
        {
            EnsureUsable();
            EnsureChildrenCompleted();

            if (_children?.Any(c => !c._isCommitted) == true)
            {
                throw new TransactionAbortedException("The transaction has aborted.");
            }

            _isCommitted = true;
            await NestedTransactionManager.RemoveAsync(this).ConfigureAwait(false);

            DiagnosticsLogger.Logger.LogInformation("Committed the transaction with id '{TransactionId}'.", TransactionId);
        }
예제 #2
0
        /// <inheritdoc />
        public virtual void Commit()
        {
            EnsureUsable();
            EnsureChildrenCompleted();

            if (_children?.Any(c => !c._isCommitted) == true)
            {
                throw new TransactionAbortedException("The transaction has aborted.");
            }

            _isCommitted = true;
            NestedTransactionManager.Remove(this);

            DiagnosticsLogger.Logger.LogInformation("Committed the transaction with id '{TransactionId}'.", TransactionId);
        }
예제 #3
0
        /// <summary>
        /// Disposes of current transaction.
        /// </summary>
        /// <param name="disposing">Indication whether this call is made by the method <see cref="Dispose(bool)"/>.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            DisposeChildren();

            if (!IsCompleted)
            {
                RollbackInternal();
            }

            NestedTransactionManager.Remove(this);
            NestedTransactionManager = null !;
            _children = null;
        }
예제 #4
0
        /// <summary>
        /// Disposes of current transaction.
        /// </summary>
        /// <param name="disposing">Indication whether this call is made by the method <see cref="DisposeAsync(bool)"/>.</param>
        protected virtual async ValueTask DisposeAsync(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            await DisposeChildrenAsync().ConfigureAwait(false);

            if (!IsCompleted)
            {
                RollbackInternal();
            }

            await NestedTransactionManager.RemoveAsync(this).ConfigureAwait(false);

            NestedTransactionManager = null !;
            _children = null;
        }
예제 #5
0
 /// <inheritdoc />
 public virtual async Task RollbackAsync(CancellationToken cancellationToken = default)
 {
     RollbackInternal();
     await NestedTransactionManager.RemoveAsync(this).ConfigureAwait(false);
 }
예제 #6
0
 /// <inheritdoc />
 public virtual void Rollback()
 {
     RollbackInternal();
     NestedTransactionManager.Remove(this);
 }