I keep getting Entity Framework errors on this snippet of code (Consistency type is an enum):
IQueryable<Examination> examinationsSet = _context.Examinations;
if (consistency.Length > 0)
{
examinationsSet = examinationsSet
.Where(x => consistency.Any(y => (int)y == (int)x.Consistency));
}
I tried adding AsQueryable or AsEnumerable between consistency and Any, but it doesn't help. This is the main error I am getting:
System.InvalidOperationException: „The LINQ expression 'Where(
source: DbSet,
predicate: (e) => Any(
source: (Unhandled parameter: __consistency_0),
predicate: (y) => (int)y == (int)e.Consistency))'
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 either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync().
Consistency? And how is EF supposed to write SQL that casts one to anint? - David Browne - Microsoft