We're setting the isolation level to Read Uncommitted as shown below.
TransactionOptions to = new TransactionOptions();
to.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew, to))
{
// Do Stuff
transaction.Complete();
}
The trouble is once the connection is returned to the pool it doesn't get reset back to the default isolation level, which I understand is by design (The transaction isolation level is not reset when you reuse a connection from the connection pool). So when the transaction finishes, anything that reuses that connection from the pool will be run with the Read Uncommitted isolation level.
I've tried calling "SET TRANSACTION ISOLATION LEVEL READ COMMITTED"
using a SqlCommand, but there's no way to guarantee it will reuse the same connection from the pool. Nothing in // Do Stuff
exposes the underlying connection.
Is there anyway to reset the isolation level without explicitly setting it on all calls to the DB just in case this code has been run previously?