Esempio n. 1
0
 public virtual void EndTransaction(EndTransactionMode mode = EndTransactionMode.Commit)
 {
     if (Transaction != null)
     {
         if (mode == EndTransactionMode.Commit)
         {
             Transaction.Commit();
         }
         else
         {
             Transaction.Rollback();
         }
         Transaction.Dispose();
         Transaction = null;
     }
 }
 /// <summary>
 /// Ends a transaction.
 /// </summary>
 /// <param name="mode">The transaction mode to commit or rollback.</param>
 /// <param name="cancellationToken">Optional cancellation token.</param>
 public void EndTransaction(EndTransactionMode mode = EndTransactionMode.Commit, CancellationToken cancellationToken = default)
 {
     if (Session != null)
     {
         if (Session.IsInTransaction)
         {
             if (mode == EndTransactionMode.Commit)
             {
                 Session.CommitTransaction(cancellationToken);
             }
             else
             {
                 Session.AbortTransaction(cancellationToken);
             }
         }
         Session.Dispose();
         Session = null;
     }
 }
 /// <summary>
 /// Ends a transaction asynchronously.
 /// </summary>
 /// <param name="mode">The transaction mode to commit or rollback.</param>
 /// <param name="cancellationToken">Optional cancellation token.</param>
 public async void EndTransactionAsync(EndTransactionMode mode = EndTransactionMode.Commit, CancellationToken cancellationToken = default)
 {
     if (Session != null)
     {
         if (Session.IsInTransaction)
         {
             if (mode == EndTransactionMode.Commit)
             {
                 await Session.CommitTransactionAsync(cancellationToken).ConfigureAwait(false);
             }
             else
             {
                 await Session.AbortTransactionAsync(cancellationToken).ConfigureAwait(false);
             }
         }
         Session.Dispose();
         Session = null;
     }
 }