Web developers use optional LINQ Skip clause when they want to bypass, specified by the count parameter, elements at the beginning of a results list and return the remaining elements. Web developers can combine the Skip clause with the Take clause to return a range of data from any segment of a query, by passing the index of the first element of the range to the Skip clause and the size of the range to the Take clause.

Web developers can use the SkipWhile clause to specify that only certain elements are ignored, depending on a supplied condition.

The next code example uses the combination of Skip and Take clause to return data from a query in pages. The GetProducts function uses the Skip clause to bypass the products in the list until the supplied starting index value, and uses the Take clause to return a page of products starting from that index value:

 

Public Sub PagingProducts()

Dim pgNum As Integer = 0

Dim pgSz    As Integer = 15

Dim productsPg =  GetProducts(pgNum*pgSz, pgSz)

Do While producsPg IsNot Nothing

Console.WriteLine(vbCrLf & “Page: ” & pgNum + 1 & vbCrLf)

For Each prd In productsPg

Console.WriteLine(prd.ProductID & “, ” & prd.Company)

Next

Console.WriteLine(vbCrLf)

pgNum = pgNum + 1

productsPg =  GetProducts(pgNum*pgSz, pgSz)

Loop

End Sub

 

 

Public Function GetProducts(ByVal begIndex as Integer, _

ByVal pgSz as Integer) as List (Of Product)

Dim products = GetProductList()

Dim result = From prod In products _

Skip begIndex Take pgSz

If result.Count = 0 Then Return Nothing

Return result

End Function

 

Your hosting company should support SQL 2008 hosting to host ASP.NET with MS SQL 2008.