Skip to main content

Custom Functions

  • 2 minutes to read

Overview

Expressions support multiple predefined functions.

  • Aggregate Functions (for example, average value).
  • Date-time Functions (for example, is today).
  • Logical Functions (for example, is null or empty).
  • Math Functions (for example, absolute value).
  • String Functions (for example, starts with).

These functions allow you to calculate values for unbound columns, implement conditional formatting or create complex filters. For example, you can only show orders that exceed the average cost and are shipped today. See Criteria Language Syntax for more information.

You can also create a custom function. For example, you can implement not starts with function.

How to Implement a Custom Function

To create a custom function, implement one of these interfaces:

Important

Do not use the function name that starts with Is if this function does not return a Boolean value. It may lead to unexpected results.

Examples

How to Register a Custom Function

A custom function should be registered in the system to make it available in expressions and/or database queries. To register a function, do one of the following:

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

Note

Refer to How to: Implement Custom Functions and Criteria in LINQ to XPO for more information on how to implement custom functions and use them in LINQ expressions created with XPO.

See Also