Show/Hide Toolbars

TMS Aurelius Documentation

Navigation: Queries

Fluent Interface

Scroll Prev Top Next More

The criteria objects you create implement a fluent interface. This means that most methods in the class will return an instance of the object itself. This is just a easier way to build your queries.

 

So instead of building the query like this:

 

var
  Results: TObjectList<TCustomer>;
  Criteria: TCriteria<TCustomer>;
  Filter: TCustomCriterion;
begin
  Criteria := Manager1.Find<TCustomer>;
  Filter := Linq['Name'] = 'Mia Rosenbaum';
  Criteria.Add(Filter);
  Results := Criteria.List;

 

You can simply write it this way:

 

var
  Results: TObjectList<TCustomer>;
begin
  Results := Manager1.Find<TCustomer>
    .Add(Linq['Name'] = 'Mia Rosenbaum')
    .List;

Almost all the examples in this chapter uses the fluent interface so you can fully understand how to use it.