Export (0) Print
Expand All

DomainContext.Load<TEntity> Method (EntityQuery<TEntity>)

WCF RIA Services

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Initiates a load operation for the specified query.

Namespace:  System.ServiceModel.DomainServices.Client
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

public LoadOperation<TEntity> Load<TEntity>(
	EntityQuery<TEntity> query
)
where TEntity : Entity

Type Parameters

TEntity

The entity type being loaded.

Parameters

query
Type: System.ServiceModel.DomainServices.Client.EntityQuery<TEntity>
The query to invoke.

Return Value

Type: System.ServiceModel.DomainServices.Client.LoadOperation<TEntity>
The load operation.

If the operation fails, an exception will be thrown.

The following example shows how to create an instance of a generated DomainContext class and load data from a query.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RIAServicesExample.Web;
using System.Windows.Ria;

namespace RIAServicesExample
{
    public partial class MainPage : UserControl
    {
        private CustomerDomainContext _customerContext = new CustomerDomainContext();

        public MainPage()
        {
            InitializeComponent();

            LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery());
            CustomerGrid.ItemsSource = loadOp.Entities;
        }
    }
}


Show:
© 2014 Microsoft