This topic shows how to page the results of a query. The example gets five Product objects after skipping the first six in the query result, which is sorted by Product.UnitPrice.
|To run the code in this example, you need to create a new Telerik OpenAccess Domain Model based on the Northwind database.|
The following code is the LINQ example.
using ( EntitiesModel dbContext = new EntitiesModel() )
IQueryable<Product> products = dbContext.Products.OrderBy( p => p.UnitPrice );
products = products.Skip( 6 ).Take( 5 );
foreach ( Product product in products )
Console.WriteLine( product.ProductName );
Using dbContext As New EntitiesModel()
Dim products As IQueryable(Of Product) = dbContext.Products.OrderBy(Function(p) p.UnitPrice)
products = products.Skip(6).Take(5)
For Each _product As Product In products