Because Expression
is a class and IEnumerable
is an interface. And classes are not covariant while interfaces and delegates are.
That means that you can't convert an Expression<A>
to Expression<B>
even if B is a base class of A.
So if this line:
() => (from c in queryable select c)
returns
Func<IQueryable<int>>
it can be converted to a
Func<IEnumerable<int>>
but if you already have
Expression<Func<IQueryable<int>>>
it can't be converted into
Expression<Func<IEnumerable<int>>>