Do I need to call dispose in the finally block for SqlTransaction? Pretend the developer didnt use USING anywhere, and just try/catch.
SqlTransaction sqlTra
In the general case, every IDisposable
object you construct or obtain, and own, you have to dispose of.
In the specific case, there are some exceptions, but SqlTransaction
is not one of them.
As per the the documentation of SqlTransaction.Dispose:
Releases the unmanaged resources used by the DbTransaction and optionally releases the managed resources.
(my emphasis)
Since the documentation does not state that those unmanaged resources are released when you issue a commit or a rollback, you will need to dispose of this object.