I would like to run one particular Linq2Sql query in snapshot isolation mode without affecting the rest of my application.
However whenever I use code like
using (var t = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.Snapshot }))
{
...
}
the Database is still using snapshot isolation after the transactionScope is finished.
I could add a dummy to reset the isolation mode like the following
using (var t = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
{
...
}
But this does not solve the problem that any queries started by other threads in between times would also be running in snapshot isolation.
It looks like, if I want to introduce a TransactionScope anywhere in my program, I have to use it everywhere.
Is that the case, or am I missing something?