Share via


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

[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)

Syntax

'Declaration
Public Function Load(Of TEntity As Entity) ( _
    query As EntityQuery(Of TEntity) _
) As LoadOperation(Of TEntity)
'Usage
Dim instance As DomainContext
Dim query As EntityQuery(Of TEntity)
Dim returnValue As LoadOperation(Of TEntity)

returnValue = instance.Load(query)
public LoadOperation<TEntity> Load<TEntity>(
    EntityQuery<TEntity> query
)
where TEntity : Entity
public:
generic<typename TEntity>
where TEntity : Entity
LoadOperation<TEntity>^ Load(
    EntityQuery<TEntity>^ query
)
member Load : 
        query:EntityQuery<'TEntity> -> LoadOperation<'TEntity>  when 'TEntity : Entity
JScript does not support generic types and methods.

Type Parameters

  • TEntity
    The entity type being loaded.

Parameters

Return Value

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

Remarks

If the operation fails, an exception will be thrown.

Examples

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

Imports System.Windows.Ria
Imports RIAServicesExample.Web

Partial Public Class MainPage
    Inherits UserControl

    Private _customerContext As New CustomerDomainContext

    Public Sub New()
        InitializeComponent()

        Dim loadOp = Me._customerContext.Load(Me._customerContext.GetCustomersQuery())
        CustomerGrid.ItemsSource = loadOp.Entities
    End Sub

End Class
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;
        }
    }
}

See Also

Reference

DomainContext Class

Load Overload

System.ServiceModel.DomainServices.Client Namespace