ListExpression

The ListExpression is part of the Dynamic Where feature; it represents the collection of WhereExpression objects.

Implementation

Example

Target SQL where clause:

WHERE City IN ('Chicago IL','Seattle WA', 'Portland OR')

 

WhereExpression where =
    new BinaryExpression(
        new FieldExpression("SALESMEN","City"),
        new ListExpression(
            new WhereExpression[]{ new ConstantExpression("Chicago IL",DataType.String),
                                   new ConstantExpression("Seattle WA", DataType.String),
                                   new ConstantExpression("Portland OR", DataType.String) }),
            BinaryOperator.In);

 

let whereExpression = BinaryExpression(
            FieldExpression("SALESMEN", "City"),
            ListExpression(
              [
                ConstantExpression("Chicago IL", DataType.String),
                ConstantExpression("Seattle WA", DataType.String),
                ConstantExpression("Portland OR", DataType.String)
              ]),
            BinaryOperator.In)

 

WhereExpression where = new BinaryExpression(
        new FieldExpression("SALESMEN","City"),
        new ListExpression(
            new WhereExpression[]{ new ConstantExpression("Chicago IL",DataType.String),
                                   new ConstantExpression("Seattle WA", DataType.String),
                                   new ConstantExpression("Portland OR", DataType.String) }),
            BinaryOperator.In);

 

let whereExpression = BinaryExpression(
            FieldExpression("SALESMEN", "City"),
            ListExpression(
              [
                ConstantExpression("Chicago IL", DataType.String),
                ConstantExpression("Seattle WA", DataType.String),
                ConstantExpression("Portland OR", DataType.String)
              ]),
            BinaryOperator.In)

 

with ClientDataModule.tbl_SALESMEN,DynamicWhere do begin
  Expression:=NewBinaryExpression(
                NewField(LogicalName,'City'), NewList(
               [NewConstant('Chicago IL',datString),
                NewConstant('Seattle WA',datString),
                NewConstant('Portland OR',datString)]),
               dboIn);
end;

 

myTable.dynamicWhere = new RemObjects.DataAbstract.DynamicWhere(
      new RemObjects.DataAbstract.BinaryExpression(
        new RemObjects.DataAbstract.FieldExpression("City"),
        new RemObjects.DataAbstract.ListExpression([
          new RemObjects.DataAbstract.ConstantExpression("String", "Chicago IL", 0),
          new RemObjects.DataAbstract.ConstantExpression("String", "Seattle WA", 0)
          new RemObjects.DataAbstract.ConstantExpression("String", "Portland OR", 0)
        ]), "In"
      )
    );

Generated XML/JSON

<?xml version="1.0"?>
<query xmlns="http://www.remobjects.com/schemas/dataabstract/queries/5.0" version="5.0">
  <where>
    <binaryoperation operator="In">
      <field tablename="SALESMEN">City</field>
      <list>
        <constant type="String" null="0">Chicago IL</constant>
        <constant type="String" null="0">Seattle WA</constant>
        <constant type="String" null="0">Portland OR</constant>
      </list>
    </binaryoperation>
   </where>
</query>
{
  "type": "query.where",
  "expression": {
    "type": "binaryoperation",
    "left": {
      "type": "field",
      "field": "City",
      "table": "SALESMEN"
    },
    "operator": "In",
    "right": {
      "type": "list",
      "items": [
        {
          "type": "constant",
          "datatype": "String",
          "value": "Chicago IL"
        },
        {
          "type": "constant",
          "datatype": "String",
          "value": "Seattle WA"
        },
        {
          "type": "constant",
          "datatype": "String",
          "value": "Portland OR"
        }
      ]
    }
  }
}