How do add NOLOCK with nHibernate?

后端 未结 7 1196
再見小時候
再見小時候 2020-11-29 03:43

How do you add NOLOCK when using nhibernate? (criteria query)

相关标签:
7条回答
  • 2020-11-29 04:19

    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

    0 讨论(0)
提交回复
热议问题