2

This issue has been asked a lot. And I find this Entity Framework with NOLOCK

When I test it, I notice that query with join

set transaction isolation level read committed

It seems that the solution only works on Single Table Query, How can I mark the Multiple Table Join Query

set transaction isolation level read uncommitted

Belowing is my test code:

class Program
    {
        static void Main(string[] args)
        {
            TransactionOptions transactionOptions = new TransactionOptions();
            transactionOptions.IsolationLevel = IsolationLevel.ReadUncommitted;

            using (var scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
            {

                using (var context = new BloggingContext())
                {                    
                    (from a in context.Set<Post>()
                     join b in context.Set<Blog>() on a.BlogId equals b.BlogId
                     select new { a, b }).FirstOrDefault();

                    context.Set<Blog>().FirstOrDefault();
                    context.Set<Blog>().ToArray();

                    scope.Complete();
                }
            }          
1pgjy
  • 149
  • 1
  • 10

0 Answers0