Telerik OpenAccess ORM

Telerik OpenAccess ORM Send comments on this topic.
How to: Page Through Query Results
See Also
Programmer's Guide > Feature Reference > API > LINQ Guide > How to: Page Through Query Results

Glossary Item Box

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.

C# Copy Code
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 );
   }
}
VB.NET Copy Code
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
  Console.WriteLine(_product.ProductName)
 Next _product
End Using

See Also