uses Aurelius.Criteria.Linq;
var
Expr: TLinqExpression;
begin
Expr := (Linq[‘A’] = 1) or (Linq[‘B’] = 2);
if Condition then
Expr := Expr or (Linq[‘C’] = 3);
Criteria.Add(Expr);
end;
ExpressionA: TLinqExpression; s: string; begin for s in sSearch.Split([' ']) do begin if ExpressionA = nil then begin < ---- this does not work of course ExpressionA := Linq.like('Bezeichnung', '%' + s + '%'); end else begin ExpressionA := ExpressionA and Linq.like('Bezeichnung', '%' + s + '%'); end;
How can I test, if a TLinqExpression already has something assigned?
Can you please provide more details? The following function compiles fine here:
function TForm4.GetLinq: TLinqExpression;
const
sFieldName = 'foo';
sFind = 'bar';
begin
Result := Linq.Eq(sFieldName, sFind);
Result := Linq.GreaterThan(sFieldName, sFind);
Result := Linq.LessThan(sFieldName, sFind);
Result := Linq.GreaterOrEqual(sFieldName, sFind);
Result := Linq.LessOrEqual(sFieldName, sFind);
Result := Linq.StartsWith(sFieldName, sFind);
Result := Linq.Contains(sFieldName, sFind);
Result := Linq.IsNull(sFieldName);
Result := Linq.IsNotNull(sFieldName);
Result := not Linq.Eq(sFieldName, sFind);
end;