码迷,mamicode.com
首页 > 其他好文 > 详细

Entity Framework with nolock. 允许脏读

时间:2016-04-12 00:24:39      阅读:455      评论:0      收藏:0      [点我收藏+]

标签:

public static List<T> ToListReadUncommitted<T>(this IQueryable<T> query)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
            {
                List<T> toReturn = query.ToList();
                scope.Complete();
                return toReturn;
            }
        }

        public static int CountReadUncommitted<T>(this IQueryable<T> query)
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
            {
                int toReturn = query.Count();
                scope.Complete();
                return toReturn;
            }
        }

Entity Framework with nolock. 允许脏读

标签:

原文地址:http://www.cnblogs.com/jianjialin/p/5380693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!