Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Expand]Data Binding Common Concepts
  [Expand]Data Source Wizard
  [Collapse]Expressions
    Expression Editor
    Expression Operators, Functions and Constants
    Implementing Custom Functions
    Member Table: Expressions
  [Expand]Behaviors
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML Text Formatting
  [Expand]Menus
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy Data and Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Implementing Custom Functions

This document explains how you can implement custom functions for CriteriaOperator-based criteria used in filter conditions and expressions supported in many DevExpress products (including grids, pivot grids, Reporting, etc.) in addition to built-in functions (see Expression Operators, Functions and Constants and FunctionOperatorType).

Note

Custom functions are not available in the visual tree of Filter Controls (FilterControl and FilterEditorControl).

Expanded Declaring Custom Functions

A custom function is a class implementing the following interfaces.

The ICustomFunctionOperatorFormattable and ICustomFunctionOperatorBrowsable interfaces inherit from the ICustomFunctionOperator interface, and extend it with a specific advanced functionality. Thus, you can implement ICustomFunctionOperatorFormattable or ICustomFunctionOperatorBrowsable (or both of them, depending on the capabilities you want to offer with your custom function) and as a result provide an ICustomFunctionOperator implementation.

Refer to the How to: Implement a Custom Criteria Language Operator for a sample ICustomFunctionOperatorFormattable interface implementation (a custom function that returns the month of a date).

Expanded Registering Custom Functions

Once a custom function is declared, you can register it in your application using any of the following methods.

  • Pass a custom function to CriteriaOperator.RegisterCustomFunction or CriteriaOperator.RegisterCustomFunctions.
    These static methods significantly simplify the registration process. With a single method call, you make custom functions available wherever CriteriaOperator-based criteria are processed - whether it is an expression or a database query built with XPO.
  • Pass a custom function to a data store provider's RegisterCustomFunctionOperator method and add it to a dictionary's XPDictionary.CustomFunctionOperators collection.
    This is an outdated registration technique, which exposes the custom function only to XPO queries based on dictionary entries.

To unregister a custom function, call the CriteriaOperator.UnregisterCustomFunction method.

To see a code example on implementing custom functions, refer to the How to: Implement a Custom Criteria Language Operator topic in the XPO documentation.


To learn how to implement custom functions and criteria, and use them in LINQ expressions built with XPO, see How to: Implement Custom Functions and Criteria in LINQ to XPO.

How would you rate this topic?​​​​​​​