Dialect/Driver - Every SELECT I perform, add with(nolock)

后端 未结 4 605
猫巷女王i
猫巷女王i 2020-12-18 17:00

I need to know a way to implement in my system, a Driver or Dialect which, whenever I perform a SELECT in Nhibernate, the SELECT adds the with(nolock) with it. I need that t

4条回答
  •  太阳男子
    2020-12-18 17:16

    Using the WITH(NOLOCK) hint is the same thing as using a READ UNCOMMITED transaction isolation level as discussed here: When should you use "with (nolock)".

    You can specify the transaction isolation level when starting new transactions with NHibernate:

    var session = SessionFactory.OpenSession();
    session.BeginTransaction(IsolationLevel.ReadUncommitted);
    

    I would not recommend this unless you really know what you are doing though. Here's some more information on the subject: Why use a READ UNCOMMITTED isolation level?.

提交回复
热议问题