Note |
---|
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience. |
Encapsulates a URI that returns the next page of a paged WCF Data Services query result.
Namespace:
System.Data.Services.ClientAssembly:
System.Data.Services.Client (in System.Data.Services.Client.dll)
Public NotInheritable Class DataServiceQueryContinuation(Of T)
Inherits DataServiceQueryContinuation
Type Parameters
-
T
-
The type of continuation token.
This example uses a do…while loop to load Customers entities from a paged results from the data service.
' Create the DataServiceContext using the service URI.
Dim context = New NorthwindEntities(svcUri)
Dim token As DataServiceQueryContinuation(Of Customer) = Nothing
Dim pageCount = 0
Try
' Execute the query for all customers and get the response object.
Dim response As QueryOperationResponse(Of Customer) = _
CType(context.Customers.Execute(), QueryOperationResponse(Of Customer))
' With a paged response from the service, use a do...while loop
' to enumerate the results before getting the next link.
Do
' Write the page number.
Console.WriteLine("Page {0}:", pageCount + 1)
' If nextLink is not null, then there is a new page to load.
If token IsNot Nothing Then
' Load the new page from the next link URI.
response = CType(context.Execute(Of Customer)(token), _
QueryOperationResponse(Of Customer))
End If
' Enumerate the customers in the response.
For Each customer As Customer In response
Console.WriteLine(vbTab & "Customer Name: {0}", customer.CompanyName)
Next
' Get the next link, and continue while there is a next link.
token = response.GetContinuation()
Loop While token IsNot Nothing
Catch ex As DataServiceQueryException
Throw New ApplicationException( _
"An error occurred during query execution.", ex)
End Try
.NET Framework
Available since 3.5
Silverlight
Available since 4.0
Any public static (
Shared
in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Return to top