DataServiceCollection<T>.Continuation DataServiceCollection<T>.Continuation DataServiceCollection<T>.Continuation DataServiceCollection<T>.Continuation Property

Definition

Ruft ein Fortsetzungsobjekt ab, das verwendet wird, um den nächsten Satz ausgelagerter Ergebnisse zurückzugeben.Gets a continuation object that is used to return the next set of paged results.

public:
 property System::Data::Services::Client::DataServiceQueryContinuation<T> ^ Continuation { System::Data::Services::Client::DataServiceQueryContinuation<T> ^ get(); void set(System::Data::Services::Client::DataServiceQueryContinuation<T> ^ value); };
public System.Data.Services.Client.DataServiceQueryContinuation<T> Continuation { get; set; }
member this.Continuation : System.Data.Services.Client.DataServiceQueryContinuation<'T> with get, set
Public Property Continuation As DataServiceQueryContinuation(Of T)

Eigenschaftswert

Ein DataServiceQueryContinuation<T>-Objekt, das den URI für die Rückgabe des nächsten Satzes ausgelagerter Ergebnisse enthält.A DataServiceQueryContinuation<T> object that contains the URI to return the next set of paged results.

Beispiele

Das folgende Beispiel ist aus der CodeBehind-Seite für eine Extensible Application Markup Language (XAML)-Seite, die das Fenster SalesOrders in WPF definiert.The following example is from the code-behind page for an Extensible Application Markup Language (XAML) page that defines the SalesOrders window in WPF. Wenn das Fenster geladen wird, wird DataServiceCollection<T> eine basierend auf dem Ergebnis einer Abfrage erstellt, die Kunden nach Land/Region filtert zurückgibt.When the window is loaded, a DataServiceCollection<T> is created based on the result of a query that returns customers, filtered by country/region. Alle Seiten dieses ausgelagerten Ergebnisses werden zusammen mit den verknüpften Bestellungen geladen und an die DataContext-Eigenschaft des StackPanel gebunden, der das Stammlayoutsteuerelement für das WPF-Fenster ist.All of the pages of this paged result are loaded, along with the related orders, and are bound to the DataContext property of the StackPanel that is the root layout control for the WPF window. Weitere Informationen finden Sie unter Vorgehensweise: Binden Sie Daten an Windows Presentation FoundationElemente.For more information, see How to: Bind Data to Windows Presentation Foundation Elements.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.Services.Client;
using NorthwindClient.Northwind;

namespace NorthwindClient
{
    public partial class CustomerOrdersWpf3 : Window
    {
        private NorthwindEntities context;
        private DataServiceCollection<Customer> trackedCustomers;
        private const string customerCountry = "Germany";
        private const string svcUri = "http://localhost:12345/Northwind.svc/";

        public CustomerOrdersWpf3()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // Initialize the context for the data service.
                context = new NorthwindEntities(new Uri(svcUri));

                // Create a LINQ query that returns customers with related orders.
                var customerQuery = from cust in context.Customers
                                    where cust.Country == customerCountry
                                    select cust;
                
                // Create a new collection for binding based on the LINQ query.
                trackedCustomers = new DataServiceCollection<Customer>(customerQuery);
                
                // Load all pages of the response at once.
                while (trackedCustomers.Continuation != null)
                {
                    trackedCustomers.Load(
                        context.Execute<Customer>(trackedCustomers.Continuation.NextLinkUri));
                }

                // Bind the root StackPanel element to the collection;
                // related object binding paths are defined in the XAML.
                LayoutRoot.DataContext = trackedCustomers;
            }
            catch (DataServiceQueryException ex)
            {
                MessageBox.Show("The query could not be completed:\n" + ex.ToString());
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("The following error occurred:\n" + ex.ToString());
            }
        }
        
        private void customerIDComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Customer selectedCustomer = 
                this.customerIDComboBox.SelectedItem as Customer;

            try
            {
                // Load the first page of related orders for the selected customer.
                context.LoadProperty(selectedCustomer, "Orders");

                // Load all remaining pages.
                while (selectedCustomer.Orders.Continuation != null)
                {
                    selectedCustomer.Orders.Load(
                        context.Execute<Order>(selectedCustomer.Orders.Continuation.NextLinkUri));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void saveChangesButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Save changes to the data service.
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports System.Data.Services.Client
Imports NorthwindClient.Northwind

Partial Public Class CustomerOrdersWpf3
    Inherits Window

    Private context As NorthwindEntities
    Private trackedCustomers As DataServiceCollection(Of Customer)
    Private Const customerCountry As String = "Germany"
    Private Const svcUri As String = "http://localhost:12345/Northwind.svc/"

    Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Try
            ' Initialize the context for the data service.
            context = New NorthwindEntities(New Uri(svcUri))

            ' Create a LINQ query that returns customers with related orders.
            Dim customerQuery = From cust In context.Customers _
                                    Where cust.Country = customerCountry _
                                    Select cust

                ' Create a new collection for binding based on the LINQ query.
            trackedCustomers = New DataServiceCollection(Of Customer)(customerQuery)

                ' Load all pages of the response at once.
            While trackedCustomers.Continuation IsNot Nothing
                trackedCustomers.Load( _
                        context.Execute(Of Customer)(trackedCustomers.Continuation.NextLinkUri))
            End While

            ' Bind the root StackPanel element to the collection
            ' related object binding paths are defined in the XAML.
            Me.LayoutRoot.DataContext = trackedCustomers
        Catch ex As DataServiceQueryException
            MessageBox.Show("The query could not be completed:\n" + ex.ToString())
        Catch ex As InvalidOperationException
            MessageBox.Show("The following error occurred:\n" + ex.ToString())
        End Try
    End Sub
    Private Sub customerIDComboBox_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim selectedCustomer As Customer = _
            CType(Me.customerIDComboBox.SelectedItem, Customer)
        Try
            If selectedCustomer.Orders.Count = 0 Then
                ' Load the first page of related orders for the selected customer.
                context.LoadProperty(selectedCustomer, "Orders")
            End If

            ' Load all remaining pages.
            While selectedCustomer.Orders.Continuation IsNot Nothing
                selectedCustomer.Orders.Load( _
                        context.Execute(Of Order)(selectedCustomer.Orders.Continuation.NextLinkUri))
            End While
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
    End Sub
    Private Sub saveChangesButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Try
            ' Save changes to the data service.
            context.SaveChanges()
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
    End Sub
End Class

Hinweise

Die Continuation-Eigenschaft gibt einen Link zurück, der verwendet wird, um auf den nächsten Satz ausgelagerter Ergebnisse zuzugreifen, wenn Paging im Datendienst aktiviert ist.The Continuation property returns a link that is used to access the next set of paged results when paging is enabled in the data service. Weitere Informationen finden Sie unter Konfigurieren des Daten Dienstanbieter.For more information, see Configuring the Data Service.

Wenn Sie ein ausgelagertes Ergebnis in eine DataServiceCollection<T> laden, müssen Sie Seiten explizit laden, indem Sie die Load(IEnumerable<T>)-Methode auf der DataServiceCollection<T> aufrufen. Hierzu übergeben Sie das Ergebnis der Ausführung des URIs, der aus der Continuation-Eigenschaft abgerufen wurde.When loading a paged result into a DataServiceCollection<T>, you must explicitly load pages by calling the Load(IEnumerable<T>) method on the DataServiceCollection<T> by passing the result of the execution of the URI that was obtained from the Continuation property.

Gilt für:

Siehe auch