Add method

Adds a new ordering expression to the given Ordering instance.

Namespace: ReFlex.Data namespace
Assembly: ReFlex.Data.dll

Syntax

public Ordering Add<T>(string expression, Direction direction)

Examples

// simple ordering for first and last name from the same type
Ordering ordering = new Ordering()
        .Add<Contact>("FirstName", Direction.Ascending)
        .Add<Contact>("LastName", Direction.Ascending));

// more complex situation where a relationship is referred to
Relationship companyRelationship = new Relationship(typeof(Company), typeof(Contact), RelationshipTypeEnum.StrongParent);
Ordering ordering = new Ordering()
        .Add<Contact>("FirstName", Direction.Ascending)
        .Add<Company>("CompanyName", Direction.Ascending));

// more complex situation where multiple relationships exist and an explicit relationship
// mapping name must be referred to
Relationship previousCompanyRelationship = new Relationship(typeof(Company), typeof(Contact), "PreviousCompany", RelationshipTypeEnum.WeakParent);
Relationship currentCompanyRelationship2 = new Relationship(typeof(Company), typeof(Contact), "CurrentCompany", RelationshipTypeEnum.WeakParent);
Ordering ordering = new Ordering()
        .Add<Contact>("FirstName", Direction.Ascending)
        .Add<Company>(new Field<Company>("CompanyName", "CurrentCompany"), Direction.Ascending);