Skip to main content

BinaryOperator Class

A logical expression which consists of a BinaryOperatorType operation between two operands.

Namespace: DevExpress.Data.Filtering

Assembly: DevExpress.Data.v24.2.dll

Declaration

public class BinaryOperator :
    CriteriaOperator

The following members return BinaryOperator objects:

Remarks

The BinaryOperator can be used in search criteria to filter objects. For more information, refer to Simplified Criteria Syntax, Criteria Operators, and NULL Value Handling Specifics.

Tip

You can find examples in the following article: Build Criteria - Cheat Sheet.

Examples

The following code demonstrates how to get a collection of “MyObject” objects that match specific criteria. The collection returned is used as a data source for a grid control. In this example, objects that have a value equal to or greater than 20 in their “UnitPrice” field are returned. To create the filter criteria a specific BinaryOperator operator is used.

using DevExpress.Xpo;
using DevExpress.Data.Filtering;

// Custom XP object.
class MyObject : XPObject {
   decimal unitPrice;

   public decimal UnitPrice {
      get { return unitPrice; }
      set { unitPrice = value; }
   }
   //...
}

// Select MyObject objects that match the specified criteria.
decimal filterValue = 20;
gridControl1.DataSource = new XPCollection(Session.DefaultSession, typeof(MyObject), 
  new BinaryOperator("UnitPrice", filterValue, BinaryOperatorType.GreaterOrEqual));

Return orders that have price more or equal to 50.

Expression:

CriteriaOperator.FromLambda<Order>(o => o.Price >= 50);
Test

Input:

OrderName

Price

Order1

30

Order2

40

Order3

50

Order4

60

The result:

OrderName

Price

Order1

50

Order2

60

Inheritance

See Also