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.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
NuGet Package: DevExpress.Xpo
Declaration
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:
- The first operand specifies the object whose type will be checked.
- 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.