While the other answers are true, note that when trying to use it after a select statement one has to call AsQueryable()
explicitly, otherwise the compiler will assume that we are trying to use IEnumerable methods, which expect a Func
and not Expression<Func>
.
This was probably the issue of the original poster, as otherwise the compiler will complain most of the time that it is looking for Expression<Func>
and not Func
.
Demo:
The following will fail:
MyContext.MySet.Where(m =>
m.SubCollection.Select(s => s.SubItem).Any(expr))
.Load()
While the following will work:
MyContext.MySet.Where(m =>
m.SubCollection.Select(s => s.SubItem).AsQueryable().Any(expr))
.Load()