BinaryExpression

The BinaryExpression is the part of the Dynamic Where feature that represents logical operations:

And Less GreaterOrEqual Like Subtraction
Or LessOrEqual NotEqual In Multiply
Xor Greater Equal Addition NotIn

It must have exactly two nodes, representing the Left and the Right expressions the operator applies to.

Implementations

Example

Target SQL Where clause:

price > 20 AND Amount <= 5

WhereExpression where =
  new BinaryExpression(
    new BinaryExpression(
      new FieldExpression("OrderDetails","price"),  
      new ConstantExpression(20),
      BinaryOperator.Greater),
    new BinaryExpression(
      new FieldExpression("OrderDetails","Amount"),  
      new ConstantExpression(5),BinaryOperator.LessOrEqual),
  BinaryOperator.And);

let whereExpression: WhereExpression = BinaryExpression(
    BinaryExpression(
        FieldExpression("OrderDetails","Price"),
        ConstantExpression(20),
    BinaryOperator.Greater
  ),
    BinaryExpression(
        FieldExpression("OrderDetails", "Amount"),
        ConstantExpression(5),
    BinaryOperator.LessOrEqual
  ),
    BinaryOperator.And
)

WhereExpression where =
    new BinaryExpression(
        new BinaryExpression(
            new FieldExpression("OrderDetails","price"),
            new ConstantExpression(20),
        BinaryOperator.Greater),
        new BinaryExpression(
            new FieldExpression("OrderDetails","Amount"),  
            new ConstantExpression(5),
        BinaryOperator.LessOrEqual),
    BinaryOperator.And);

let whereExpression: WhereExpression = BinaryExpression(
    BinaryExpression(
        FieldExpression("OrderDetails","Price"),
        ConstantExpression(20),
    BinaryOperator.Greater
  ),
    BinaryExpression(
        FieldExpression("OrderDetails", "Amount"),
        ConstantExpression(5),
    BinaryOperator.LessOrEqual
  ),
    BinaryOperator.And
)

with tbl_OrderDetails, DynamicWhere do begin
    Expression:=NewBinaryExpression(
      NewBinaryExpression(NewField(LogicalName,'price'),
          NewConstant(20),dboGreater),
      NewBinaryExpression(NewField(LogicalName,'Amount'),
          NewConstant(5),dboLessOrEqual),
    dboAnd);
end;

myTable.dynamicWhere = new RemObjects.DataAbstract.DynamicWhere(
  new RemObjects.DataAbstract.BinaryExpression(
        new RemObjects.DataAbstract.BinaryExpression(
            new RemObjects.DataAbstract.FieldExpression("price"),
            new RemObjects.DataAbstract.ConstantExpression("Byte", 20),
        "Greater"),
        new RemObjects.DataAbstract.BinaryExpression(
            new RemObjects.DataAbstract.FieldExpression("Amount"),
            new RemObjects.DataAbstract.ConstantExpression("Byte", 5),
        "LessOrEqual"),
    "And"
  )
);

Generated XML

<?xml version="1.0"?>
<query xmlns="http://www.remobjects.com/schemas/dataabstract/queries/5.0" version="5.0">
  <where>
    <binaryoperation operator="And">
      <binaryoperation operator="Greater">
        <field tablename="OrderDetails">price</field>
        <constant type="Byte" null="0">20</constant>
      </binaryoperation>
      <binaryoperation operator="LessOrEqual">
        <field tablename="OrderDetails">Amount</field>
        <constant type="Byte" null="0">5</constant>
      </binaryoperation>
    </binaryoperation>
  </where>
</query>