Всех с Наступающим!
помогите с исключением, не могу понять из-за чего исключение
public static class NoLock
{
public static List<T> ToListWithNoLock<T>(this IQueryable<T> query, Expression<Func<T, bool>> expression = null)
{
List<T> result = default;
using (var scope = CreateTrancation())
{
if (expression != null)
{
query = query.Where(expression);
}
result = query.ToList();
scope.Complete();
}
return result;
}
private static TransactionScope CreateTrancation()
{
return new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions()
{
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted
},
TransactionScopeAsyncFlowOption.Enabled);
}
}
var t = context.Transactions.AsNoTracking().Where(x => x.IdUserIn == ID_USER && ID_USER > 0 && x.State == "N" && (DateTime.Now - x.Created).TotalHours < 24).ToListWithNoLock();
The LINQ expression 'DbSet<Transaction>()
.Where(t => t.IdUserIn == __ID_USER_0 && True && t.State == "N" && (DateTime.Now — t.Created).TotalHours < 24)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See
https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
или как иначе на EF CORE переписать
select COUNT(*) from TRANSACTIONS with (nolock) where ((@IP<>0 and ip=@IP) or (@ID_USER>0 and ID_USER_IN=@ID_USER)) and state='N' and datediff(HOUR, CREATED, getdate())<24