Consider the following:
using (var outerScope = new TransactionScope())
{
InsertDataInTableOne();
InsertDataInTableTwo();
InsertDataInTableThree();
outerScope.Complete();
}
Now I want to have InsertDataInTableOne
to be run outside of the outerScope
transaction. This is a simplified representation, as the TransactionScope
is created several calls up the chain, so I can't just put the call to InsertDataInTableOne
outside of the TransactionScope
creation.
I also know this might not be a good practice, and we're working on a decent fix. But we need this quick fix at this moment.
using (var outerScope = new TransactionScope())
{
using (var innerScope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
InsertDataInTableOne();
innerScope.Complete();
}
InsertDataInTableTwo();
InsertDataInTableThree();
outerScope.Complete();
}
That didn't work. I even tried with creating a TransactionScope
with Suppress
first, and then the RequiresNew
.
So is it possible to insert data immediately in the database, effectively ignoring the fact that you are in a TransactionScope
?
The connection is made outside of these methods (actually, when entering the service that is called).