Here is the signature of the MaxBy
extension method:
public static TSource MaxBy<TSource, TKey>(this IEnumerable<TSource> source,
Func<TSource, TKey> selector)
{
return source.MaxBy(selector, Comparer<TKey>.Default);
}
It returns the maximal element (based on the given projection) of an IEnumerable<T>
, not an IQueryable<T>
. So the results of the query db.TheBigTable
are indeed all loaded into memory first, and then they are iterated to find the maximum.