This link describes the class DBSet.This type implements IQueryable, what means, that it has to have an implementation for AsQueryable(). But in the list in the link I cannot find this method. Can somebody tell me why?
My initial answer while hopefully useful was not entirely correct as pointed out by Eli Arbel so I have rewritten it.
The DbSet<TEntity>
class has a complicated inheritance hierarchy. Here is a UML diagram showing just part of it.
The method AsQueryable<TEntity>()
is an extension method defined on IEnumerable<TEntity>
that converts the IEnumerable<TEntity>
into an IQueryable<TEntity>
and as DbSet<TEntity>
implements IEnumerable<TEntity>
you are able to use the extension method:
IQueryable<MyEntity> queryable = myDbSet.AsQueryable();
However, it is not very useful because DbSet<TEntity>
also implements IQueryable<TEntity>
so calling AsQueryable()
will simply return the IQueryable<TEntity>
interface. You might as well write the snippet above as:
IQueryable<MyEntity> queryable = myDbSet;
This behavior is explained in the documentation for Queryable.AsQueryable()
which is the documentation you are looking for.
It is correct that the linked documentation page does include a lot of extension methods but as the universe of possible extension methods in principle is unbounded there is no guarantee that all extension methods will be in the list. In particular both AsQueryable()
and AsEnumerable()
are missing.