Export (0) Print
Expand All

DataServiceQueryContinuation<T> Class

Encapsulates a URI that returns the next page of a paged query result.

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

public sealed class DataServiceQueryContinuation<T> : DataServiceQueryContinuation

Type Parameters

T

The type of continuation token.

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 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);
}

System.Object
  System.Data.Services.Client.DataServiceQueryContinuation
    System.Data.Services.Client.DataServiceQueryContinuation<T>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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:
© 2014 Microsoft