EntitySpaces™ Query API

The EntitySpaces Dynamic Query mechanism is 100% provider independent. The syntax is created by the EntitySpaces data provider. This means that a dynamic query written against one DBMS system will run on all DBMS systems supported by EntitySpaces.

Basic Select

Query

Yields

Default Conjunction

By default "AND" is used, but that can be overridden.

Query

Yields

Query - Sets the DefaultConjunction to "OR"

Yields

Count

Query

Yields

Query

Yields

Aggregates

Avg, Count, Min, Max, Sum, StdDev, and Var all share the same syntax.

Query - An Aggregate with an Empty Alias uses the Column Name

Yields

Query - Simple Aggregate with Alias

Yields

Query - Two Aggregates

Yields

Query - Aggregate with Distinct

Yields

Query - Aggregate with Count

Yields

Query - Aggregate with Where clause

Yields

Group By

Query

Yields

Query - With two GroupBy's and a Where clause

Yields

Query - Select, Where, GroupBy, and OrderBy

Yields

Query - Select, Where, GroupBy, WithRollup, and OrderBy

Yields

Operators in Queries

Query

Yields

Query

Yields

Distinct and Top in Queries

Query - Distinct Rows

Yields

Query - Top 5

Yields

Mixing And/Or Queries

Query

Yields

Simplifying Queries

Let's simplify the query above to something more readable. Of course, the queries below yield the same sql so it's not relisted

Query - Cache the Query object in a local variable

Query - Better yet, add a method directly to your concrete query class

Conditionally Building and Reseting Queries

Queries can be built up by adding individual Select or Where clauses. To flush a Query out, use QueryReset().

 
VB.NET notes for the Query API

One of the nice things about the EntitySpaces DynamicQuery API is that the differences between C# and VB.NET are neglible. Remove the semi-colon from the end of the line and you are done. VB.NET does not have an '==' operator. Use the standard syntax instead:

emps.Query.Name.Equal("Doe")

Hierachical Methods and the Query API

At their heart, the EntitySpaces hierarchical methods use the DynamicQuery mechanism to lazy-load all columns for just the related rows. Do not try to combine additional DynamicQuery statements with the hierarchical sub-object, as this interferes with the built-in methods.

Wrong:

emps.TerritoryCollection.Query.
  Where(...);

The hierarchical methods are very useful, but if you only want specific columns or a sub-set of rows, you should create a custom load in one of your custom classes.

search       
Copyright © 2005 - 2007, EntitySpaces, LLCPrivacy StatementTerms Of Use