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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top