Export (0) Print
Expand All

How to: Enable Paging of Data Service Results (ADO.NET Data Services)

Note Note

This topic describes new functionality in ADO.NET Data Services that is available as an update to the .NET Framework version 3.5 Service Pack 1. You can download and install the update from the Microsoft Download Center.

ADO.NET Data Services enables you to limit the number of entities returned by a data service query. Page limits are defined in the method that is called when the service is initialized, and can be set separately for each entity set.

When paging is enabled, the final entry in the feed contains a link to the next page of data. For more information, see Configuring the Data Service (ADO.NET Data Services).

This topic shows how to modify a data service to enable paging of returned Customers and Orders entity sets. The example in this topic uses the Northwind sample data service. This service is created when you complete the ADO.NET Data Services quickstart.

How to enable paging of returned Customers and Orders entity sets

  • In the code for the data service, replace the placeholder code in the InitializeService function with the following:

    config.SetEntitySetPageSize("Customers", 8);
    config.SetEntitySetPageSize("Orders", 5);
    
    config.DataServiceBehavior.MaxProtocolVersion =
        System.Data.Services.Common.DataServiceProtocolVersion.V2;
    
    
    

Community Additions

Show:
© 2014 Microsoft