How to: Load Paged Results (WCF Data Services)

 

WCF Data Services enables the data service to limit the number of entities that are returned in a single response feed. When this happens, the final entry in the feed contains a link to the next page of data. The URI for the next page of data is obtained by calling the GetContinuation method of the QueryOperationResponse<T>, which is returned when the DataServiceQuery<TElement> is executed. The URI represented by this object is then used to load the next page of results. For more information, see Loading Deferred Content.

The example in this topic uses the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the WCF Data Services quickstart.

This example uses a do…while loop to load Customers entities from a paged results from the data service.

[!CODE [Astoria Northwind Client#GetCustomersPaged](../CodeSnippet/VS_Snippets_Misc/astoria northwind client#getcustomerspaged)]

This example returns related Orders entities with each Customers entity and uses a do…while loop to load Customers entities pages and a nested while loop to load pages of related Orders entities from the data service.

[!CODE [Astoria Northwind Client#GetCustomersPagedNested](../CodeSnippet/VS_Snippets_Misc/astoria northwind client#getcustomerspagednested)]

Loading Deferred Content
How to: Load Related Entities

Show: