ConstantExpression
The ConstantExpression is part of the Dynamic Where feature; it represents a constant in where
expressions.
Implementation
- ConstantExpression (.NET)
- ConstantExpression (Java)
- TDAConstantExpression (Delphi)
- ConstantExpression (JavaScript)
Example
Target SQL where
clause:
WHERE LASTNAME = 'Frank'
WhereExpression where = new BinaryExpression(
new FieldExpression("SALESMEN","LastName"),
new ConstantExpression("Frank", DataType.String),
BinaryOperator.Equal
);
let whereExpression = BinaryExpression(
FieldExpression("SALESMEN", "LastName"),
ConstantExpression("Frank", DataType.String),
BinaryOperator.Equal)
WhereExpression where = new BinaryExpression(
new FieldExpression("SALESMEN","LastName"),
new ConstantExpression("Frank", DataType.String),
BinaryOperator.Equal);
let whereExpression = BinaryExpression(
FieldExpression("SALESMEN", "LastName"),
ConstantExpression("Frank", DataType.String),
BinaryOperator.Equal)
with ClientDataModule.tbl_SALESMEN, DynamicWhere do begin
Expression:=NewBinaryExpression(
NewField(LogicalName,'LastName'),
NewConstant('Frank', datString),
dboEqual);
end;
myTable.dynamicWhere = new RemObjects.DataAbstract.DynamicWhere(
new RemObjects.DataAbstract.BinaryExpression(
new RemObjects.DataAbstract.FieldExpression("LastName"),
new RemObjects.DataAbstract.ConstantExpression("String", "Frank"), "Equal")
));
Generated XML/JSON
<?xml version="1.0"?>
<query xmlns="http://www.remobjects.com/schemas/dataabstract/queries/5.0" version="5.0">
<where>
<binaryoperation operator="Equal">
<field tablename="SALESMEN">LastName</field>
<constant type="String" null="0">Frank</constant>
</binaryoperation>
</where>
</query>
{
"type": "query.where",
"expression": {
"type": "binaryoperation",
"left": {
"type": "field",
"field": "LastName",
"table": "SALESMEN"
},
"operator": "Equal",
"right": {
"type": "constant",
"datatype": "String",
"value": "Frank"
}
}
}