Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

A product uses query aspects to attach snippets of query code to a MetaClass or MetaLayout.

One common example is for setting default sorts on a meta-class.

A product can indicate how a meta-class should be sorted by default as follows (assuming the code is inside a builder).

The example below sets the standard sorting for a person.

Elements.PersonBuilder.DefaultSort("LastName");
Elements.PersonBuilder.DefaultSort("FirstName");

The example above is already optimal, but let's examine below how we could write it using a query aspect.

Elements.PersonBuilder.Filter(
    q => q.OrderBy("LastName").OrderBy("FirstName")
  )
);

The example above is trivial, but the aspect can include any query elements it wants.

The following base classes should suffice for most purposes:

  • ActionBasedQueryAspect: As shown above, provides a way of extending the query for a property or class. The example above is anonymous, but the aspects can also be named so that a product can add multiple aspects of the same type.

  • ActionBasedQueryAspect<T>: An ActionBasedQueryAspect that provides the source object when the query aspect is on a relation (e.g. if the query aspect is on the relationship from person => company, the source person is provided)

  • No labels