Why doesn't IQueryable have all the extension methods that IQueryable <T> has?
From docs :
The IQueryable interface is designed to be implemented by query providers. Providers are supposed to also implement
IQueryable<T>. If the provider also does not implementIQueryable<T>, the standard query operators cannot be used in the provider data source.
IEnumerable is an artifact of the time when .NET did not have generics (I do not want to say that it is deprecated, of course). It lived for backward compatibility after generics, and therefore IEnumerable<T> was introduced. IQueryable does not lag behind the sequence. In principle, given that there are generics now, and taking into account the benefits, it makes sense to implement these extensions only on common interfaces. Non-original can always be converted to general using Cast<T>
No, this is not supervision. Most methods that extend IQueryable<T> and IEnumerable<T> need to know the type of elements. Obviously, methods such as Count() or Any() could work on non-generic interfaces, but it would probably be confusing. Thus, the only methods that apply to non-common interfaces are those that make them generalized ( Cast<T>() and OfType<T>() ).
This was probably a deliberate decision, not a supervision, since IEnumerable\IQueryable can always be converted to IEnumerable\IQueryable<object> using the Cast method.
This introduces a small overhead for the caller, but retains two implementation options, for example, for Where you will need a general and non-general version:
public static IEnumerable Where(this IEnumerable source, Func<object, bool> predicate) { ... } public static IEnumerable<T> Where<T>(this IEnumerable<T> source, Func<T, bool> predicate) { ... }