共用方式為


DataServiceQueryContinuation<T> 類別

封裝一個傳回下一頁 WCF Data Services 分頁式查詢結果的 URI。 

繼承階層

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

命名空間:  System.Data.Services.Client
組件:  Microsoft.Data.Services.Client (在 Microsoft.Data.Services.Client.dll 中)

語法

'宣告
Public NotInheritable Class DataServiceQueryContinuation(Of T) _
    Inherits DataServiceQueryContinuation
'用途
Dim instance As DataServiceQueryContinuation(Of T)
public sealed class DataServiceQueryContinuation<T> : DataServiceQueryContinuation
generic<typename T>
public ref class DataServiceQueryContinuation sealed : public DataServiceQueryContinuation
[<SealedAttribute>]
type DataServiceQueryContinuation<'T> =  
    class
        inherit DataServiceQueryContinuation
    end
JScript 不支援泛型型別及方法。

型別參數

  • T
    接續語彙基元的型別。

DataServiceQueryContinuation<T> 型別公開下列成員。

屬性

  名稱 說明
公用屬性 NextLinkUri 取得用於從分頁式查詢結果傳回下一頁資料的 URI。 (繼承自 DataServiceQueryContinuation。)

上層

方法

  名稱 說明
公用方法 Equals (繼承自 Object。)
受保護的方法 Finalize (繼承自 Object。)
公用方法 GetHashCode (繼承自 Object。)
公用方法 GetType (繼承自 Object。)
受保護的方法 MemberwiseClone (繼承自 Object。)
公用方法 ToString 傳回下一個連結 URI 做為字串。 (繼承自 DataServiceQueryContinuation。)

上層

範例

此範例使用 do...while 迴圈,從資料服務的分頁式結果載入 Customers 實體。

' 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
// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);
DataServiceQueryContinuation<Customer> token = null;
int pageCount = 0; 

try
{ 
    // Execute the query for all customers and get the response object.
    QueryOperationResponse<Customer> response =
        context.Customers.Execute() as QueryOperationResponse<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++);

        // 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<Customer>(token)
                as QueryOperationResponse<Customer>;
        }

        // Enumerate the customers in the response.
        foreach (Customer 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 (DataServiceQueryException ex)
{
    throw new ApplicationException(
        "An error occurred during query execution.", ex);
}

執行緒安全性

這個型別的任何公用 static (在 Visual Basic 中為 Shared) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。

請參閱

參考

System.Data.Services.Client 命名空間

其他資源

載入延後的內容 (WCF Data Services)