Up Query
DevForce Resource Center » Development guide » Query » Query without using LINQ

Query without using LINQ

Last modified on August 15, 2012 17:22

In addition to the EntityQuery which supports the entire .NET LINQ syntax stack, DevForce provides several other query types that do not support LINQ syntax

These are the EntityKeyQuery, PassthruEsqlQuery and StoredProcQuery types for queries using EntityKeys, Entity SQL and stored procedures, respectively. 

Like the EntityQuery, these types all implement DevForce’s IEntityQuery interface.

Unlike the EntityQuery<T>, these query types are not composable, meaning that additional clauses cannot be tacked onto them to further restrict or project the query results into another form. In addition, the PassthruESQLQuery and the StoredProcQuery types do not provide in-memory querying capabilities.

What these queries do provide that the EntityQuery<T> does not is that they may offer, depending on the use case, better integration with existing database constructs, special functionality or improved performance. However, in most cases the EntityQuery<T> is usually a better choice, because of its greater flexibility.

Sample PassthruEsqlQuery

C#
PassthruEsqlQuery query = new PassthruEsqlQuery(typeof(Employee),
 "SELECT VALUE e FROM Employees AS e Where e.EmployeeID < 10");
IEnumerable results = _em1.ExecuteQuery(query);
VB
Dim query As New PassthruEsqlQuery(GetType(Employee), _
 "SELECT VALUE e FROM Employees AS e Where e.EmployeeID < 10")
Dim results As IEnumerable = _em1.ExecuteQuery(query)

Sample StoredProcQuery

C#
QueryParameter param01 = new QueryParameter("EmployeeID",1);
QueryParameter param02 = new QueryParameter("Year",1996);
StoredProcQuery query = new StoredProcQuery(typeof(Order));
query.Parameters.Add(param01);
query.Parameters.Add(param02);
// Note that a FunctionImport must be defined in the Entity Model
query.ProcedureName = "OrdersGetForEmployeeAndYear";
_em1.ExecuteQuery(query);
VB
Dim param01 As New QueryParameter("EmployeeID", 1)
Dim param02 As New QueryParameter("Year", 1996)
Dim query As New StoredProcQuery(GetType(Order))
query.Parameters.Add(param01)
query.Parameters.Add(param02)
' Note that a FunctionImport must be defined in the Entity Model
query.ProcedureName = "OrdersGetForEmployeeAndYear"
_em1.ExecuteQuery(query)
Created by DevForce on September 30, 2010 13:46

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade