IDbTransaction.Dispose() behavior

  • Thread starter Thread starter Alexander Myachin
  • Start date Start date
A

Alexander Myachin

Hello,

I have noticed that during Dispose() uncommitted transaction is
automatically rolled back .
This behavior is exactly what i am expecting, but I have not found any
reference in the documentation .

Can I safely rely on such behavior in my code?

Thanks in advance,
Alexander Myachin
 
When you dispose a transaction object we check to see if the connection that
it is associated with is still active, if it is then we call rollback
Rollback can throw an exception, but before rethrowing the exception we
guarantee the rollback.
If the connection is closed with an active transaction the transaction is
automatically rolled back.

So yes, you can safely rely on dispose rolling back your transaction in all
cases.
Hope this helps,
 
Back
Top