The problem is that Queryable.GroupBy()
returns IQueryable<IGrouping<TKey, TSource>>
, where IGrouping<TKey, TSource>
implemens IEnumerable<TSource>
, but not IQueryable<TSource>
.
And I believe your code wouldn't work anyway, because ItemsOfColor()
wouldn't be actually called. Instead, the EF would get an expression that calls ItemsOfColor()
. And since it doesn't know that method, it would throw an exception.