Thursday, May 6, 2010

LINQ to SQL Serverside paging

Retrieve Products with Server Side Paging

The code below demonstrates how to implement efficient server-side database paging as part of a LINQ query. By using the Skip() and Take() operators below, we'll only return 10 rows from the database - starting with row 200.

Northwinddata db = new Northwinddata();

var products = from p in db.Products where p.Category.CategoryName.startwith("c")
select p).skip(200).Take(10);

1 comment: