I've seen examples of code where a TransactionScope is nested inside another like this
using(TransactionScope scope1 = new TransactionScope())
{
try
{
//Start of non-transactional section
using(TransactionScope scope2 = new
TransactionScope(TransactionScopeOption.Suppress))
{
//Do non-transactional work here
}
//Restores ambient transaction here
}
catch
{}
//Rest of scope1
}
I can understand here the use of Supress
but as far as I understand Required
just merges with the outer Transaction, so that if anything fails, the whole thing fails, so what's the point? Am I missing something here?
EDIT: Just to be clear I want to emphasize that the Suppress option I (think I :-)) understand, which is explained in the MSDN documentation. My question is on the default Required option; maybe I don't fully understand but if Transaction B is nested inside Transaction A then if either A fails or B fails then both A and B will be rolled back, which is the same if I never put B in a transaction in the first place.
So the question reworded is 'What is the difference between nesting a Transaction with the default Required option, and not doing it all?'