Show/Hide Toolbars

TMS Aurelius Documentation

Navigation: Queries

Projections

Scroll Prev Top Next More

You can make even more advanced queries in Aurelius by using projections. For example, instead of selecting pure object instances (TCustomer for example) you can perform grouping, select sum, average, a function that retrieves the year of a date, among others. There is a formal definition for projection, but you can think of a projection just as an expression that returns a value, for example, a call to Sum function, a literal, or the value of a property.

 

Usually you will use projections to return specific/calculated values instead of objects, or to perform complex condition expressions (to retrieve all customers where the year of birthday column is equal to 1999).

 

For example, the following query retrieves the number of invoices for the year 2013 and illustrates how to use projections in both select and where parts of the query.

 

uses {...}, Aurelius.Criteria.Linq, Aurelius.Criteria.Projections;
 
TotalInvoicesFor2013 := Manager.Find<TInvoice>
  .Select(TProjections.Count('Id'))
  .Where(Linq['IssueDate'].Year = 2013)
  .UniqueValue;

 

The following topics explain in details what projections are and how you can use them.

 

Projections Overview

Creating Projections Using TProjections

Aggregated Functions

Prop

Group

Condition

Literal<T>

Value<T>

ProjectionList

Alias

Sql Projection

Year

Month

Day

Hour

Minute

Second

Upper

Lower

Length

ByteLength

Substring

Position