Generated code - QuerySpec, creating predicates with fields and expressions

By default LLBLGen Pro defines several operator overloads on EntityField(2) classes to produce predicates. It also defines on the Expression class a couple of operator overloads to produce expressions quickly. To make things easier and more fluent, a list of extension methods have been defined for IExpression and IEntityFieldCore objects to produce predicates, as well as other objects. The methods defined are:

The extension methods can be used directly on the expression or field:

...
.Where((OrderDetailFields.Quantity * OrderDetailFields.Price).Equal(500))

Concatenating predicates with .And/.Or/.AndNot/.OrNot

To create longer predicates, you can use the following extension methods to create a predicate expression from two IPredicate operands: .And(predicate) / .Or(predicate) / .AndNot(predicate) / .OrNot(predicate).

Converting a predicate to boolean value

A predicate isn't a boolean value in a SQL query. QuerySpec inherits this aspect. This means that when you use a predicate as a boolean value in other areas than a Where clause (e.g. as a value in the projection or Order by), the predicate has to be converted to a boolean value. This is done by appending the predicate with the extension method AsBooleanValue(). This method wraps the predicate with a CASE WHEN (predicate) THEN 1 ELSE 0 END statement.

Field operators: Like / StartsWith / EndsWith / Contains(string)

To produce Like predicates, the developer has a couple of options:


LLBLGen Pro Runtime Framework v4.1 documentation. ©2013 Solutions Design bv