views:

90

answers:

1

When Commit is called (for the implementation of IEnlistmentNotification) can I just throw an exception to indicate I want the transaction to rollback?

A: 

You should instead call Transaction.Rollback(Exception ex):

   public void Commit(Enlistment enlistment)
   {
      Transaction currentTx = Transaction.Current;
      if (currentTx != null)
      {
         currentTx.RollBack(new Exception("I give up!");
      }
   }
Mike Atlas