Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Collapse]Concepts
  [Expand]Application Solution Components
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]UI Construction
  [Expand]Extend Functionality
  [Expand]Data Manipulation and Business Logic
  [Expand]Security System
  [Expand]Localization
  [Expand]System Module
  [Expand]Extra Modules
  [Expand]Debugging, Testing and Error Handling
  [Collapse]Filtering
    Criteria Property of a List View's Collection Source
    Criteria Property in the Application Model
    Filters Application Model Node
    ListViewFilter Attribute
    FullTextSearch Action
    UI-Specific Filtering Techniques
    Adjust Data Sources for Reference and Collection Properties
    Ways to Build Criteria
    Object Parameters
    Current Object Parameter
    Function Criteria Operators
    Custom Function Criteria Operators
  [Expand]Application Life Cycle
 [Expand]Design-Time Features
 [Expand]Deployment
 [Expand]Task-Based Help
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Function Criteria Operators

The eXpressApp Framework provides various approaches to filter List Views: on the data source level, via the Application Model and special methods for filtering Lookup Property Editors' List Views. In each approach, you may need to set static variables as filter criteria values. For example, the filter "Task.DueDate must be set to the current date" needs the CurrentDate variable (calculated each time it is required). For this purpose, use the Function Criteria Operators which represent functions that return a particular value (such as the current date or the current user) or a result of handling the specified arguments (such as the concatenation function). This topic describes Function Criteria Operators, shows how to use them when filtering, and explains how to implement Custom Function Operators.

Expanded Function Criteria Operators Basics

Function Criteria Operators are a part of the criteria language. In criteria strings, a Function Criteria Operator name should be followed by brackets containing operands that represent function arguments, or empty brackets if it does not take arguments. The following criterion demonstrates how to use the LocalDateTimeToday Operator:

[Task.DueDate] = LocalDateTimeToday()

Multiple Function Criteria Operators, such as LocalDateTimeAfterTomorrow or Replace, are available out of the box. Refer to the FunctionOperatorType help topic for a complete list. The following table lists the XAF-specific Function Criteria Operators available in XAF applications:

Operator                        DescriptionExamples
CurrentUserId() Returns the current user's identifier. This custom Function Criteria Operator is registered in the SystemModule's ModuleBase.CustomizeTypesInfo method override. This Operator's Evaluate method returns the SecuritySystem.CurrentUserId property value.
User.Oid = CurrentUserId()
IsCurrentUserInRole(roleName) Determines whether the currently logged on user is assigned to a specified role. Returns false when no user is currently logged on. The SecurityModule registers this custom Function Criteria Operator in the XafApplication.LoggedOn event handler if SecuritySystem.CurrentUser implements the IUserWithRoles or ISecurityUserWithRoles interfaces. This Operator's Evaluate method casts the SecuritySystem.CurrentUser property value to the IUserWithRoles and ISecurityUserWithRoles interfaces and checks that the Roles collection contains the specified role.
IsCurrentUserInRole('Admin')
IsNewObject(obj) Applicable to XPO objects only. Indicates whether a specified object has been created but not saved to the database. This operator's Evaluate method gets the current Object Space using the static XPObjectSpace.FindObjectSpaceByObject method and then returns the XPObjectSpace.IsNewObject result, and returns false if the Object Space is not found. You can use this Operator on the client-side only; do not use it in security permissions criteria.
IsNewObject(This)
IsNewObject(Manager)

Expanded Important Remark on the DateTime Function Criteria Operators

The DateTime parameters do not support the addition and subtraction operations. The following expression is incorrect:

[Task.DueDate] > (LocalDateTimeToday() - 3) AND [Task.DueDate] < (LocalDateTimeToday() + 3)

To add or subtract values from the DateTime parameters, use the DateTime management functions the XPO exposes, such as AddDays and AddYears. For instance, this is the correct way to write the previous criterion:

[Task.DueDate] > ADDDAYS(LocalDateTimeToday(), -3) AND [Task.DueDate] < ADDDAYS(LocalDateTimeToday(), 3)

For a complete list of functions with descriptions, refer to the Criteria Language Syntax help topic.

Note

DateTime parameters support plain addition and subtraction operations in certain database management systems (DBMS) – there are no errors when such an expression is evaluated on the server side. For example, when filtering a List View via the ListViewFilterAttribute, the criterion is processed on the server. If the server supports addition and subtraction operations for the DateTime parameters (for example, MS SQL Server or MS Jet Database Engine), the criterion is correctly processed.

Expanded Limitations of Function Criteria Operators used in Mobile Applications

Note the following limitations when using Function Criteria Operators in Mobile applications:

  • When filtering a data source:

  • When configuring a UI using the Conditional Appearance Module:

    • Custom Function Criteria Operators should be evaluable on the server-side.
    • The Abs, Acos, Ascii, Asin, Atn2, Atn, BigMul, Ceiling, Char, Cos, Cosh, Exp, Floor, Log10, Log, Max, Min, Power, Rnd, Round, Sign, Sin, Sinh, Sqr, Tan, Tanh, UtcNow Function Criteria Operators are not supported.

Expanded See Also

Is this topic helpful?​​​​​​​