I highly recommend reading about SQL Server transaction isolation modes before using ReadUncommitted. Here is a very good read.
http://blogs.msdn.com/b/davidlean/archive/2009/04/06/sql-server-nolock-hint-other-poor-ideas.aspx
In many cases, the ReadSnapshot
level should be sufficient. Also you, if you really need it. You can set the default transaction isolation level for your database using
Set Transaction Isolation Level
Other good ideas include packaging. Your context is in a shell that encapsulates each call using the required isolation level. (maybe you need nolock 95% of the time and serializable 5% of the time). This can be done using extension methods or regular methods using code like:
viewData.Categories = northwind.Categories.AsReadCommited().ToList();
Which takes your IQueryable and does the trick mentioned by Rob.
Hope this helps Luke
source share