Skip to content

Terminating operations

Malcolm Groves edited this page Jan 9, 2014 · 6 revisions

In simple terms, a Terminating Operation is one that stops you from adding further query operations.

In the following query:

Query.EndsWith('e') 

EndsWith is not a Terminating Operation, as we can continue on to specify further operations, like so:

Query.EndsWith('e').StartsWith('a')

However, Predicate is a Terminating Operation, as it is not possible to specify further query operations. It effectively marks the end of your query.

Query.EndsWith('e').Predicate

In more strict terms, a Terminating Operation is one that does not return a Query Enumerator (Bound or Unbound) as Non-terminating Operations do. Sticking to our string query example above:

Query.EndsWith('e') 

returns an IUnboundStringQueryEnumerator which contains further query operations.

Query.From(Listbox1.Items).EndsWith('e')

returns an IBoundStringQueryEnumerator, which also contains further query operations.

Query.EndsWith('e').Predicate

returns a TPredicate<String>, which does not contain any query operations.

It follows that as for..in loops operate on Enumerators, only Unterminated Queries (ie. queries containing no Terminating Operations) can be used in a for..in loop.

Clone this wiki locally