Export (0) Print
Expand All

EntityQuery Class

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.]

Represents a query method invocation.

System.Object
  System.ServiceModel.DomainServices.Client.EntityQuery
    System.ServiceModel.DomainServices.Client.EntityQuery<TEntity>

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

public abstract class EntityQuery

The EntityQuery type exposes the following members.

  NameDescription
Public propertyDomainClientGets the DomainClient for this query.
Public propertyEntityTypeGets the type this query retrieves data from.
Public propertyHasSideEffectsGets a value indicating whether the query has side-effects.
Public propertyIncludeTotalCountGets or sets a value indicating whether the TotalEntityCount property is required.
Public propertyIsComposableGets a value indicating if the query supports composition.
Public propertyParametersGets the parameters required by the query method.
Public propertyQueryGets the underlying IQueryable for the query.
Public propertyQueryNameGets the name of the query method.
Top

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

In your client application, you can apply additional filtering on a query to limit which entities are returned. You use LINQ and a subset of LINQ query operators to modify the results returned from the query. The following lists the available query operators:

  • Where

  • OrderBy

  • ThenBy

  • Skip

  • Take

After you apply additional filtering, you pass the EntityQuery object as a parameter in the Load method to execute the query and get the results. If the query has a QueryAttribute with the IsComposable property set to false, you cannot apply additional filtering on the query. Generally, only queries that return a single entity will have IsComposable set to false.

The following code shows how to retrieve customers from the domain service. It filters customers who have phone numbers that start with 583 and orders them alphabetically by LastName. The results are displayed in a DataGrid.

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

    public MainPage()
    {
        InitializeComponent();
        EntityQuery<Customer> query = 
            from c in _customerContext.GetCustomersQuery()
            where c.Phone.StartsWith("583")
            orderby c.LastName
            select c;
        LoadOperation<Customer> loadOp = this._customerContext.Load(query);
        CustomerGrid.ItemsSource = loadOp.Entities;
    }
}


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