What is the difference between IQueryable and DbQuery?

Following this question / answer How to make the Entity Framework Data Context read

The solution is to make your DbContext collections of type DbQuery, but it's a pretty specialized type (it's buried in namespaces for EF).

So what is the functional difference between DbContext with this:

public DbQuery<Customer> Customers
{
    get { return Set<Customer>().AsNoTracking(); }
}

vs this:

public IQueryable<Customer> Customers
{
    get { return Set<Customer>().AsNoTracking(); }
}

... EF documentation is very easy when it comes to the DbQuery class, but I prefer the DbContext to consist of interfaces rather than classes, so I would like to avoid it. What additional benefits does the DbQuery class provide?

Update

, , . , , ! , DbQuery , . , IQueryable - . !

+4
1

DBQuery - LINQ to Entities DbContext. LINQ . , IQueryable.

IOrderedQueryable

. , OrderBy, OrderByDescending, ThenBy ThenByDescending. CreateQuery , , IQueryable , IOrderedQueryable.

IListSource 

, .

IDbAsyncEnumerable

IEnumerable, . Entity Framework .

+3

Source: https://habr.com/ru/post/1568783/


All Articles