示例#1
0
 /// <summary>
 /// Used when a connection is closed
 /// </summary>
 public void 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.
             _npgsqlTx.Cancel();
             _npgsqlTx.Dispose();
             _npgsqlTx = null;
         }
     }
 }
示例#2
0
 public void Enlist(Transaction tx)
 {
     if (tx != null)
     {
         _isolationLevel = tx.IsolationLevel;
         if (!tx.EnlistPromotableSinglePhase(this))
         {
             // must already have a durable resource
             // start transaction
             _npgsqlTx      = _connection.BeginTransaction(ConvertIsolationLevel(_isolationLevel));
             _inTransaction = true;
             _rm            = CreateResourceManager();
             _callbacks     = new NpgsqlTransactionCallbacks(_connection);
             _rm.Enlist(_callbacks, TransactionInterop.GetTransmitterPropagationToken(tx));
             // enlisted in distributed transaction
             // disconnect and cleanup local transaction
             _npgsqlTx.Cancel();
             _npgsqlTx.Dispose();
             _npgsqlTx = null;
         }
     }
 }
		public void Enlist(Transaction tx)
		{
			if (tx != null)
			{
				_isolationLevel = tx.IsolationLevel;
				if (!tx.EnlistPromotableSinglePhase(this))
				{
					// must already have a durable resource
					// start transaction
					_npgsqlTx = _connection.BeginTransaction(ConvertIsolationLevel(_isolationLevel));
					_inTransaction = true;
					_rm = CreateResourceManager();
					_callbacks = new NpgsqlTransactionCallbacks(_connection);
					_rm.Enlist(_callbacks, TransactionInterop.GetTransmitterPropagationToken(tx));
					// enlisted in distributed transaction
					// disconnect and cleanup local transaction
					_npgsqlTx.Cancel();
					_npgsqlTx.Dispose();
					_npgsqlTx = null;
				}
			}
		}