I saw a type like DBSet, it may implement both IQueryable and IEnumerable like below:
public class DbSet<TEntity> : DbQuery<TEntity>, IDbSet<TEntity>, IQueryable<TEntity>, IEnumerable<TEntity>, IEnumerable, IQueryable, ...
And obviously IQueryable inherits IEnumerable, And in System.Linq namespace, both Enumerable static class and IQueryable static class defined some extension method operators like First(), Select() for both IQueryable and IEnumerable,
I wonder in some invocation like
DBSet<Student> studs = dbContext.Students;
var stu = studs.First();
It is obviously that public static TSource First<TSource>(this IQueryable<TSource> source); method in IQueryable static class is get called.
From C# specification(7.6.5.2), it said:
If namespaces imported by using namespace directives in the given namespace or compilation unit directly contain non-generic type declarations Ci with eligible extension methods Mj, then the set of those extension methods is the candidate set.
But in my case, Enumerable and IQueryable class both in System.Linq namespace, I wonder in this situation how is public static T First<T>(this IQueryable<T> source) is being decided and called ?