GetContinuation Method
Collapse the table of content
Expand the table of content

QueryOperationResponse<T>.GetContinuation Method

Gets a DataServiceQueryContinuation<T> object that contains the URI that is used to retrieve the next results page.

Namespace:  System.Data.Services.Client
Assembly:  System.Data.Services.Client (in System.Data.Services.Client.dll)

public DataServiceQueryContinuation<T> GetContinuation()

Return Value

Type: System.Data.Services.Client.DataServiceQueryContinuation<T>
An object that contains the URI that is used to return the next results page.

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.

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

// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
DataServiceQueryContinuation<Customers> token = null;
int pageCount = 0; 

try
{ 
    // Execute the query for all customers and get the response object.
    QueryOperationResponse<Customers> response =
        context.Customers.Execute() as QueryOperationResponse<Customers>;

    // 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++);

        // If nextLink is not null, then there is a new page to load. 
        if (token != null)
        {
            // Load the new page from the next link URI.
            response = context.Execute<Customers>(token)
                as QueryOperationResponse<Customers>;
        }

        // Enumerate the customers in the response. 
        foreach (Customers customer in response)
        {
            Console.WriteLine("\tCustomer Name: {0}", customer.CompanyName);
        }
    }

    // Get the next link, and continue while there is a next link. 
    while ((token = response.GetContinuation()) != null);
}
catch (Exception ex)
{
    throw new ApplicationException(
        "An error occurred during query execution.", ex);
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1

Community Additions

ADD
Show:
© 2016 Microsoft