Npgsql.NpgsqlConnection.PromotableLocalTransactionEnded C# (CSharp) Method

PromotableLocalTransactionEnded() private method

When a connection is closed within an enclosing TransactionScope and the transaction hasn't been promoted, we defer the actual closing until the scope ends.
private PromotableLocalTransactionEnded ( ) : void
return void
        internal void PromotableLocalTransactionEnded()
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "PromotableLocalTransactionEnded");
            if (_postponingDispose)
                Dispose(true);
            else if (_postponingClose)
                ReallyClose();
        }

Usage Example

 /// <summary>
 /// Used when a connection is closed
 /// </summary>
 public void Prepare()
 {
     Log.Debug("Prepare");
     if (_inTransaction)
     {
         // may not be null if Promote or Enlist is called first
         if (_callbacks == null)
         {
             _callbacks = new NpgsqlTransactionCallbacks(_connection);
         }
         _callbacks.PrepareTransaction();
         if (_npgsqlTx != null)
         {
             // cancel the NpgsqlTransaction since this will
             // be handled by a two phase commit.
             _connection.Connector.ClearTransaction();
             _npgsqlTx.Dispose();
             _npgsqlTx = null;
             _connection.PromotableLocalTransactionEnded();
         }
     }
 }
All Usage Examples Of Npgsql.NpgsqlConnection::PromotableLocalTransactionEnded