I want to filter a dbset using a where clause but both predicates dont work when using AsQueryable
and
the exception:
The linq expression could not be translated
is thrown
...
var objects = myObject; //Ienumerable
return await dbset.AsQueryable()
.Where(entity => objects.Any(obj => obj.uId == entity.uId && obj.cId == entity.cId))
.ToArrayAsync(cancellationToken)
.ConfigureAwait(false); // not working
return await dbset.AsQueryable().
Where(entity => objects.Contains(new Object(entity.cId, entity.uId))
.ToArrayAsync(cancellationToken)
.ConfigureAwait(false); // also not working
When I change AsQueryable
to AsEnumerable
it is working but since the set can be quite large I want to stick with AsQueryable
. How could I rewrite the where clause so that the exception
is not thrown?