Back to Devexpress

Upcasting (Combine Data from Base and Derived Classes)

expressappframework-112797-business-model-design-orm-business-model-design-with-xpo-use-xpo-upcasting-in-xaf.md

latest1.4 KB
Original Source

Upcasting (Combine Data from Base and Derived Classes)

  • Nov 01, 2024
  • 4 minutes to read

This topic demonstrates how to use Upcasting in XAF. This functionality is useful when you need to combine base and derived classes in a single query.

We suggest that you implement the following business model for this example:

  1. Expand the MySolution.Module project and right-click the Business Objects folder. Choose Add | Class…. Specify UpcastingDataModel.cs as the new class name and click Add. Replace the auto-generated code with the following class declaration:

  2. If your application uses Entity Framework Core, register the following classes in the DbContext:

  3. Run the application and invoke the Department Detail View:

  4. To add required columns, invoke the Model Editor. Navigate to the Views | MySolution.Module.BusinessObjects | EmployeeBase | Department_Employees_ListView | Columns node. Use the context menu to add two child nodes and assign the following values to the PropertyName properties of these nodes:

  5. Run the application and invoke the Department Detail View. XAF now displays the properties of the EmployeeBase class and its descendants.