What I want know is if a given SQLConnection is enlisted with the current ambient transaction in a given time, I mean, putting something in the watch while debugging that allow me know if one connection is enlisted with the current ambient transaction. I'm debugging code that create several instances of TransactionScope class and the code not call neither TransactionScope.Complete or TransactionScopeDispose before new instances of TransactionScope are created. So if I could know if a given SQLConnection is enlisted in the current ambient transaction will be very useful.

BTW, the TransactionScope is not created using usingstatement, so is hard know reading the code what SQLConnection belong to what TransactionScope instance.

1

There are 1 best solutions below

0
On

The enlisted transaction is stored in the SqlInternalConnection's EnlistedTransaction field. This field is set here in the EnlistNonNull method. You can get access to that field with reflection.