Back to Devexpress

Map a Persistent Class to a Database View Which Has No Key Field

expressappframework-113281-business-model-design-orm-business-model-design-with-xpo-map-a-persistent-class-to-a-database-view-which-has-no-key-field.md

latest2.6 KB
Original Source

Map a Persistent Class to a Database View Which Has No Key Field

  • Feb 20, 2026
  • 4 minutes to read

With XAF, you can build new applications from scratch or maintain existing databases. The How to: Generate XPO Business Classes for Existing Data Tables topic describes how to use the design-time wizard that generates business classes for one or more data tables in the specified database at the same time. Additionally, the existing database can contain views (stored queries), which need to be accessed in an XAF application’s List Views, Analysis, and Reports. If the database view has a key column, you can map a persistent class to it using the same approach as mapping to a regular table.

This topic describes how to implement a persistent class mapped to a database view without a key.

Note

This approach uses composite keys, which are not supported in the ASP.NET Core Blazor applications, and works only for WinForms applications.

  1. Create a new XAF solution and follow the steps from the How to: Generate XPO Business Classes for Existing Data Tables topic. Do not forget to modify the connection string that connects your application to the nwind.mbd database.

  2. Open the nwind.mbd database to see what views (queries) it contains. You can use Microsoft Office Access or any other MDB viewer application. In this example, the CustomerReports view is mapped to the CustomerReports persistent class:

  3. Create a new CustomerReports persistent class (you can use the DevExpress 25.2 ORM Persistent Object template). Replace the automatically generated class declaration with the following code:

  4. Run the application. The “Customer Reports” object is available.

See Also

XPLiteObject

KeyAttribute

PersistentAttribute

Base Persistent Classes

Generate XPO Business Classes for Existing Data Tables

How to map a persistent object to a view which does not have a key column