Skip to main content

IsInstanceOfTypeFunction Class

A custom function that determines whether a particular object is of a specified type or derives from it.

Namespace: DevExpress.Xpo.Metadata

Assembly: DevExpress.Xpo.v23.2.dll

NuGet Package: DevExpress.Xpo

Declaration

public class IsInstanceOfTypeFunction :
    ICustomFunctionOperatorBrowsable,
    ICustomFunctionOperator,
    ICustomFunctionDisplayAttributes,
    ICustomFunctionOperatorConvertibleToExpression,
    ICustomFunctionOperatorCompileable

Remarks

This function is automatically registered in XPO applications. So, you can use it right from the start.

The IsInstanceOfTypeFunction custom function operator takes 2 operands:

  1. The first operand specifies the object whose type will be checked.
  2. The second operand specifies the fully qualified name of the required type.

Assume you have a collection of Employee objects. Employees can either be objects of the LocalEmployee, LocalTemporaryEmployee, or ForeignEmployee types:

public class LocalEmployee : Employee { /* ... */ }

public class LocalTemporaryEmployee : LocalEmployee { /* ... */ }

public class ForeignEmployee : Employee { /* ... */ }

The following code snippet demonstrates how the employees collection can be filtered to contain only local employees, including the temporary ones.

using DevExpress.Xpo;
using DevExpress.Data.Filtering;
//...
XPCollection<EmployeeBase> employees = new XPCollection<EmployeeBase>(Session);
employees.Criteria = CriteriaOperator.Parse("IsInstanceOfType(This, ?)", typeof(LocalEmployee).FullName);

The IsInstanceOfTypeFunction function is automatically registered in XPO applications.

Inheritance

Object
IsInstanceOfTypeFunction
See Also