From the course: .NET Essentials: LINQ for Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Paging with Take and Skip

Paging with Take and Skip - .NET Tutorial

From the course: .NET Essentials: LINQ for Databases

Start my 1-month free trial

Paging with Take and Skip

- [Illustrator] There is another technique for returning a reduced set of rows from the database, it's called Take and Skip. And the benefit of this is we can get a limited set of rows without writing a where clause. And the typical use of this is when you want to page data. So you have a 1000 rows worth of data, you only want to show the user 10 of those items. So you show them the first 10 and when they click on the next page button, you show them the next 10 items. So we're going to use Take and Skip to make this happen. This is what it says in the Microsoft documentation. Take returns a number of continuous elements from the start of the sequence and Skip bypasses a number of elements in sequence and then returns the remaining elements. So we combine these two to build our pages. Here's our query. I'm getting the products, ordering them by Product ID and then selecting out three properties. Product ID, product…

Contents