Entity Framework с NOLOCK

С помощью методов расширения c-sharp это можно упростить

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

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

c#

entity-framework

ado.net

2022-11-16T21:34:36+00:00
Вопросы с похожей тематикой, как у вопроса:

Entity Framework с NOLOCK