How do you add NOLOCK when using nhibernate? (criteria query)
This doesn't add NOLOCK to your queries that I can tell, but it should provide the same functionality - which is to perform dirty reads only inside a transaction.
Session.BeginTransaction(IsolationLevel.ReadUncommitted);
I used Sql Profiler to see what the above command would do but it didn't change anything about the query or add NOLOCK to them (nhibernate uses sp_executesql for most my queries). I ran with it anyway, and it appears all the deadlocks are gone. Our software has been running this way for 3 days now without deadlocks. Before this change I could usually reproduce the deadlocks within 15 minutes. I'm not 100% convinced this fixed it but after another weeks worth of testing I will know more.
This has worked for others as well: http://quomon.com/NHibernate-deadlock-problem-q43633.aspx