Is there a way to check if code is executed in a TransactionScope?
Something like:
if(TransactionScope.Started|Enabled){...}
Is there a way to check if code is executed in a TransactionScope?
Something like:
if(TransactionScope.Started|Enabled){...}
You could check the Transaction.Current property:
if(Transaction.Current != null)
{
// running inside a transaction
}
Hi,
yes there is way (directly copied from the MSDN documentation of TransactionScope):
The ambient transaction is the transaction your code executes in. You can obtain a reference to the ambient transaction by calling the static Current property of the Transaction class.
So have a look at Transaction.Current.