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 - .NET Tutorial
From the course: .NET Essentials: LINQ for Databases
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
-
-
-
-
-
-
-
(Locked)
Projection, get fewer columns2m 19s
-
(Locked)
Paging with Take and Skip1m 49s
-
(Locked)
Use Find for faster search by key1m 58s
-
(Locked)
Use EF navigation properties instead of joins3m 4s
-
(Locked)
Use the Contains method for1m 36s
-
(Locked)
Organize query results into groups with GroupBy3m 7s
-
(Locked)
Flatten child collections with SelectMany1m 36s
-
(Locked)
Find data within a date range1m 20s
-
(Locked)
-