IdeaBlade DevForce 2010 Help Reference
ExecuteQuery(IEntityQuery) Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityManager Class > ExecuteQuery Method : ExecuteQuery(IEntityQuery) Method



query
Executes the specified query.

Syntax

Visual Basic (Declaration) 
Public Overloads Function ExecuteQuery( _
   ByVal query As IEntityQuery _
) As IEnumerable
Visual Basic (Usage)Copy Code
Dim instance As EntityManager
Dim query As IEntityQuery
Dim value As IEnumerable
 
value = instance.ExecuteQuery(query)
C# 
public IEnumerable ExecuteQuery( 
   IEntityQuery query
)
C++/CLI 
public:
IEnumerable^ ExecuteQuery( 
   IEntityQuery^ query
) 

Parameters

query

Return Value

A collection of IEntityQuery.ElementType

Example

C#Copy Code
public void ExecuteQuerySamples() {
  DomainModelEntityManager mgr = new DomainModelEntityManager();

  // 1a) Query by type 
  EntityQuery<Customer> query1a = mgr.Customers;
  IEnumerable<Customer> results1a = mgr.ExecuteQuery<Customer>(query1a);
  // 1b) Query by type with a query strategy
  EntityQuery<Customer> query1b = mgr.Customers.With(QueryStrategy.CacheOnly);
  IEnumerable<Customer> results1b = mgr.ExecuteQuery<Customer>(query1b);
  // 1c) Query by type using immediate execution
  List<Customer> results1c = mgr.Customers.ToList();

  // 2a) Query by EntityKey
  EntityKey key = new EntityKey(typeof(Customer), "ALFKI");
  var customer2a = key.ToQuery().FirstOrNullEntity();
  // 2b) Query by EntityKey with a query strategy
  var customer2b = key.ToQuery().With(QueryStrategy.CacheOnly).FirstOrNullEntity();

  // 3a) Query by a list of EntityKeys
  EntityKeyList keys = new EntityKeyList(typeof(Customer));
  keys.Add(new EntityKey(typeof(Customer), "ALFKI"));
  keys.Add(new EntityKey(typeof(Customer), "BONAP"));
  EntityKeyQuery query3a = keys.ToQuery();
  var results3a = mgr.ExecuteQuery(query3a);
  // 3b) Query by a list of EntityKeys with query strategy
  var results3b = mgr.ExecuteQuery(query3a.With(QueryStrategy.CacheOnly));

  // 4a) Query with an EntityQuery
  IEntityQuery<Customer> q4 = mgr.Customers.Where(c => c.CustomerID.StartsWith("A"));
  IEnumerable<Customer> results4a = mgr.ExecuteQuery<Customer>(q4);
  // 4b) Query with an EntityQuery and query strategy
  IEnumerable<Customer> results4b = mgr.ExecuteQuery<Customer>(q4.With(QueryStrategy.CacheOnly));
}

Remarks

In Silverlight, this query can only execute against the cache because this method is synchronous.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.