Paging
An important feature of any database access technology is the ability to page through large sets of data. Compile-time checking is also great. If you are sorting by a particular field and later remove this field from the model, a compile-time error will be generated since everything is strongly-typed. Ordering is very important when paging, since the next page of objects returned must be deterministic. That said, you can order by any number of fields.
using (var context = new NorthwindEntities())
{
//Load all customers with first name 'Chris'
//Get records 51-60
var customerList = context.Customer.
Where(x => x.FirstName == "Chris")
.OrderBy(x=>x.FirstName)
.Skip(50)
.Take(10)
.ToList();
}
Or you can use the convenience method syntax.
using (var context = new NorthwindEntities())
{
//Use the Paging object and specify a Where and OrderBy clause
var paging = new nHydrate.EFCore.DataAccess.Paging(50, 10);
var customerList = context.Customer.GetPagedResults(
x => x.ContactName == "Chris",
x => x.ContactName,
paging);
}