LinqToSql With NOLOCK
This has been something I’ve been meaning to figure out how to do for ages, luckily I stumbled on a great solution by a smart guy named Omar Al Zabir. You can find his full write up here:
Sometimes you just want a cheap call to populate some info pages, you know it’s a heavy call and you don’t want to lag anything up. You can do it like this:
using (DeniedDataContext db = new DeniedDataContext())
db.ExecuteCommand(“SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;”); // The important line.
You’ll also need to extend your data context like so or you could start leaking connections.
public class DeniedDataContext : DCDBDataContext, IDisposable
public new void Dispose()
if (base.Connection != null)
if (base.Connection.State != System.Data.ConnectionState.Closed)