Skip to main content
A newer version of this page is available. .

ConstantValue Class

A constant value operand in criteria expressions.

Namespace: DevExpress.Data.Filtering

Assembly: DevExpress.Data.v18.1.dll

Declaration

public class ConstantValue :
    OperandValue

The following members accept/return ConstantValue objects:

Remarks

Normally, criteria value operands (OperandValue objects) are automatically passed as standard parameters to the resulting SQL queries, generated based on criteria expressions. The ConstantValue allows you to embed in-line parameters into the resulting SQL queries. With in-line parameters, you can improve performance when executing a number of SQL queries with matching constants passed as parameters. To accomplish this, replace OperandValue with ConstantValue in your criteria expression as shown below.

Examples


CriteriaOperator filter = new BinaryOperator(new OperandProperty("LastName"), 
    new ConstantValue("Smith"), BinaryOperatorType.Equal);

The CriteriaOperator.Parse method automatically translates constant operand values to ConstantValue counterparts. So, the following line produces the same criteria.


CriteriaOperator filter = CriteriaOperator.Parse("LastName = 'Smith'");

If you pass constant operand values using positional parameters (see the corresponding section in Criteria Language Syntax), they are translated, as usual, to OperandValue objects, not ConstantValue objects. The following code will produce criteria with normal query parameters, rather than in-line.


CriteriaOperator filter = CriteriaOperator.Parse("LastName = ?, "Smith");

 

Note

In-line parameters are supported for Int32, Boolean, String, and Enum operand values.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ConstantValue class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

See Also