NOLOCK with Linq to SQL

后端 未结 5 616
小鲜肉
小鲜肉 2020-11-30 23:01

Is it possible to get Linq2Sql to emit a NOLOCK in its SQL? And if so, how?

5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 23:15

    A simple way may be to run a command on your DataContext class

    using (var dataContext = new DataContext())
    {
      dataContext.ExecuteCommand("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
    
      // Your SQL query
    }
    

提交回复
热议问题