TechTalk Genome v4.2

Sorting

set .OrderBy(
[[alias:] order-clause-1 (ascending|descending)],
[[alias:] order-clause-2 (ascending|descending)],
...,
[[alias:] order-clause-n (ascending|descending)])
alias
An identifier used to alias the candidate element of set. If alias is specified, the this keyword refers to the candidate element declared in any outer scope (the semantics of the this keyword are not altered when an explicit alias is used). If omitted, the this keyword can be used to refer to the candidate element of set.
order-clause-1, order-clause-2, ..., order-clause-n
One or more OQL implicit functions executed on candidate elements of set, returning scalar values or persistent objects. The return values of the expressions are used to specify the order of the elements in the set.
ascending
Specifies that the values in the specified ordering expression should be sorted in ascending order, from lowest value to highest value.
descending
Specifies that the values in the specified ordering expression should be sorted in descending order, from highest value to lowest value.
set
An OQL expression returning a Set<T> of scalars or persistent objects.

Return Value

A Set<T> containing the elements of set lexicographically ordered by the order-clause-1, order-clause-2, ..., order-clause-n expressions in the specified direction.

Remarks

The order-clause-1 expression is evaluated for each element of set and the result is sorted by the values returned by the expression. If the order-clause-1 expression returns the same value for two elements in the set, the order-clause-2, ..., order-clause-n expressions are evaluated and compared to define the order of the elements. If the last expression order-clause-n returns the same value for two elements in the set, the order of these elements is undefined in the resulting Set<T>.

If order-clause-i returns a persistent value, the identity fields of the returned value are used to determine the sort order. If the returned value has more than one identity field, the resulting Set<T> is ordered lexicographically by the identity fields of the returned value in the order specified in the <PrimaryKey> element.

alias (if present) can be used to refer to the candidate element of set; otherwise, the this keyword can be used.

Quick Reference

OQL
extentof(Animal).OrderBy([Name ascending])


extentof(Animal).OrderBy([Age descending], [Name ascending])

C#
Set<Animal> animals = myDB.Extent<Animal>().OrderBy("Name ascending");


Set<Animal> animals = myDB.Extent<Animal>().OrderBy("Age descending, Name ascending");

SQL
SELECT * FROM Animal ORDER BY Name ASC


SELECT * FROM Animal ORDER BY Age DESC, Name ASC

Examples

    <Member name="Orders" 
        Oql="extentof(Order)[o: o.Customer == this].OrderBy([o: o.Product.Name ascending])" />

See Also

Set´1.Order | Implicit Functions | OqlReference.Chapter9