EntityQuery<TEntity> Class

[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 LINQ query over a collection of entities.

Inheritance Hierarchy

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)

Syntax

'Declaration
Public NotInheritable Class EntityQuery(Of TEntity As Entity) _
    Inherits EntityQuery
'Usage
Dim instance As EntityQuery(Of TEntity)
public sealed class EntityQuery<TEntity> : EntityQuery
where TEntity : Entity
generic<typename TEntity>
where TEntity : Entity
public ref class EntityQuery sealed : public EntityQuery
[<SealedAttribute>]
type EntityQuery<'TEntity when 'TEntity : Entity> =  
    class
        inherit EntityQuery
    end
JScript does not support generic types and methods.

Type Parameters

  • TEntity
    The entity type.

The EntityQuery<TEntity> type exposes the following members.

Properties

  Name Description
Public property DomainClient Gets the DomainClient for this query. (Inherited from EntityQuery.)
Public property EntityType Gets the type this query retrieves data from. (Inherited from EntityQuery.)
Public property HasSideEffects Gets a value indicating whether the query has side-effects. (Inherited from EntityQuery.)
Public property IncludeTotalCount Gets or sets a value indicating whether the TotalEntityCount property is required. (Inherited from EntityQuery.)
Public property IsComposable Gets a value indicating if the query supports composition. (Inherited from EntityQuery.)
Public property Parameters Gets the parameters required by the query method. (Inherited from EntityQuery.)
Public property Query Gets the underlying IQueryable for the query. (Inherited from EntityQuery.)
Public property QueryName Gets the name of the query method. (Inherited from EntityQuery.)

Top

Methods

  Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)

Top

Extension Methods

  Name Description
Public Extension Method OrderBy<TEntity, TKey> Applies the specified ascending order clause to the source query. (Defined by EntityQueryable.)
Public Extension Method OrderByDescending<TEntity, TKey> Applies the specified descending order clause to the source query. (Defined by EntityQueryable.)
Public Extension Method Select<TEntity> Applies the specified selection to the source query. (Defined by EntityQueryable.)
Public Extension Method Skip<TEntity> Applies the specified skip clause to the source query. (Defined by EntityQueryable.)
Public Extension Method Take<TEntity> Applies the specified take clause to the source query. (Defined by EntityQueryable.)
Public Extension Method ThenBy<TEntity, TKey> Applies the specified ascending order clause to the source query. (Defined by EntityQueryable.)
Public Extension Method ThenByDescending<TEntity, TKey> Applies the specified descending order clause to the source query. (Defined by EntityQueryable.)
Public Extension Method Where<TEntity> Applies the specified filter to the source query. (Defined by EntityQueryable.)

Top

Remarks

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

Examples

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.

Partial Public Class MainPage
    Inherits UserControl

    Private _customerContext As New CustomerDomainContext

    Public Sub New()
        InitializeComponent()

        Dim query As EntityQuery(Of Customer)

        query = _
            From c In Me._customerContext.GetCustomersQuery() _
            Where c.Phone.StartsWith("583") _
            Order By c.LastName

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

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

Thread Safety

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

See Also

Reference

System.ServiceModel.DomainServices.Client Namespace