TechTalk Genome v4.2

Set.OrderBy Method 

Returns a Set containing the same elements as the source Set with the sort order defined by the specified OQL order clause.

public Set OrderBy(
   string orderBy,
   params object[] parameters
);

Parameters

orderBy
An OQL order clause consisting of comma-separated list of one or more OQL expressions and order specifications. The expression may contain zero or more literal parameter references and it can refer to the candidate element of the source Set using the this keyword.
parameters
An array of zero or more objects that can be used as literal argument values in orderBy.

Return Value

A Set that has a default sort order defined by the specified OQL order clause and contains the same elements as the source Set.

Remarks

The order direction ("ascending" or "descending") have to be defined for each of the specified OQL expressions in the orderBy parameter.

Exceptions

Exception TypeCondition
OqlParserExceptionorderBy does not denote a valid OQL order clause.
SqlDomException

orderBy is not applicable to the element type of the source Set.

or

orderBy can not be translated to the target SQL language.

SchemaExceptionorderBy contains expressions or features that cannot be translated with the given DataDomainSchema.

Example


For example there is a DataDomain instance named GenomeDataDomain, and the following persistent class:

                    
public abstract class Employee : Persistent
{
    public abstract int EmployeeID { get; }

    public abstract string LastName { get; set; }
    public abstract string FirstName { get; set; }
    public abstract string Title { get; set; }
    public abstract string TitleOfCourtesy { get; set; }
    public abstract DateTime BirthDate { get; set; }
    public abstract DateTime HireDate { get; set; }
    public abstract string Address { get; set; }
    public abstract string City { get; set; }
    public abstract string Region { get; set; }
    public abstract string PostalCode { get; set; }
    public abstract string Country { get; set; }
    public abstract string HomePhone { get; set; }
    public abstract string Extension { get; set; }
    public abstract byte[] Photo { get; set; }
    public abstract string Notes { get; set; }
    public abstract string PhotoPath { get; set; }

    public abstract Employee ReportsTo { get; set; }
    …
}
                    
                

Retrieveing all employees ordered by their lastname:
                    
...
// Ascending
Set employees = GenomeDataDomain.Extent(typeof(Employee)).OrderBy("LastName ascending");
...

or

...
// Descending
Set employees = GenomeDataDomain.Extent(typeof(Employee)).OrderBy("LastName descending");
...
                    
                

Retrieveing all employees ordered by their lastname and title:
                    
...
Set employees = GenomeDataDomain.Extent(typeof(Employee)).OrderBy("LastName ascending, Title descending");
...
                    
                

Retrieveing all employees ordered by the person's lastname who they report to:
                    
...
Set employees = GenomeDataDomain.Extent(typeof(Employee)).OrderBy("ReportsTo.LastName ascending");
...
                    
                

Requirements

Namespace: TechTalk.Genome

Assembly: TechTalk.Genome (in TechTalk.Genome.dll)

Version: 4.2.4.4

Editions: Professional, Evaluation, Express

See Also

Set Class | TechTalk.Genome Namespace | Sorting