windowsforms-9947-common-features-expressions-implementing-custom-functions.md
Expressions support multiple predefined functions.
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.
To create a custom function, implement one of these interfaces:
ICustomFunctionDisplayAttributes - a custom function accessible in expression editors, filter editors and filter menus.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.
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:
Pass the function to the static (Shared in VB) CriteriaOperator.RegisterCustomFunction or CriteriaOperator.RegisterCustomFunctions method.
Pass the function to a data storage provider’s RegisterCustomFunctionOperator method and add it to a dictionary’s XPDictionary.CustomFunctionOperators collection.
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