[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Collapse]Grid View
   [Expand]Product Information
    Getting Started
    Grid Designer
   [Expand]Visual Elements
     How to: Add an Unbound Column to Supply Additional Data
     How to: Add and Initialize a New Row
     How to: Add Custom Filter Values to the Filter Dropdown
     How to: Bind the ASPxGridView to Data Created at Runtime (DataTable)
     How to: Bind to an ArrayList
     How to: Change the Style Settings of Individual Data Cells
     How to: Create an ASPxGridView at Runtime
     How to: Create and Customize a Group Summary
     How to: Create Custom Command Buttons
     How to: Create Edit Form Template at Runtime
     How to: Create Total Summaries
     How to: Delete Selected Rows
     How to: Display a Context Menu For Column Headers
     How to: Display Images within Preview Rows
     How to: Display Master-Detail Data (XPO)
     How to: Display Real-Time Data
     How to: Dynamically Change Images Displayed Within Data Cells
     How to: Dynamically Display the Focused Row's Values Outside the ASPxGridView
     How to: Export ASPxGridView Data as a PDF
     How to: Filter Data by Multiple Columns
     How to: Filter Records
     How to: Generate Persistent Objects for Existing Data Tables
     How to: Hide Expand Buttons for Master Rows That Have Empty Details
     How to: Implement Custom Grouping
     How to: Implement Custom Sorting
     How to: Implement Data Editing When a Grid is Bound to a Table Created At Runtime
     How to: Implement Master-Detail at Runtime (XPO)
     How to: Obtain Server Data From the Client
     How to: Present Data in Cards
     How to: Provide Custom Display Text for Data Cells
     How to: Render a Different Content From Default Exporting
     How to: Save and Restore the ASPxGridView's Layout
     How to: Save Changes and Switch to Browse Mode by Clicking ENTER
     How to: Select Rows That Contain the Specified Value
     How to: Show Detail Information in a Separate ASPxGridView
     How to: Sort Groups by Summary Values
     How to: Switch ASPxGridView to an Edit Mode by Double-Clicking a Row
     How to: Use a Hyperlink Whose Argument Depends on Several Cell Values in the ASPxGridView
     How to: Validate Data On the Client
   [Expand]Member Tables
  [Expand]Tree List
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Generate Persistent Objects for Existing Data Tables

The eXpress Persistent Objects library provides a design-time wizard that allows you to generate persistent objects for one or more data tables in your database. Only specify connection settings to the database, and select target tables and columns. The wizard will automatically generate persistent objects for the selected tables.


Data tables whose primary keys are composed of several columns are not supported by XPO. The wizard will not process these tables.

Expanded Generating Persistent Objects

  1. In the Solution Explorer, add a new project to the solution.

    Name is 'BusinessObjects'.

  2. Select the Add->New Item... context menu option.

  3. Select the Persistent Classes item in the dialog window and click Add.

  4. The wizard will open and ask you to specify connection settings to the database containing the target data table(s).

    The wizard displays all database engines supported by XPO. Use the Provider combo box to select the required database type. Note that the corresponding database provider assembly must be registered in the Global Assembly Cache (GAC) on your machine or the wizard will fail.

    Click Next after connection settings have been specified.

  5. In the next step, the wizard displays a list of tables that can be mapped to persistent objects. A table whose primary key is composed of several columns will be unavailable for selection.

    Select a table(s) to be mapped to a persistent object(s), and for each table select columns that will be mapped to the persistent object's properties. For unchecked columns, persistent properties will not be generated.

    The names of persistent classes and their properties will match the names of selected tables and their columns. To rename the classes and properties, use the Rename buttons in the Tables and Columns panes. The classes and properties with modified names will still be mapped to corresponding tables and columns using the PersistentAttribute attribute.

    Click Finish to close the wizard and generate the persistent classes. Below is a code snippet of such a class.

  6. Add a reference to the BusinessObjects project and rebuild the solution.

Expanded Binding ASPxGridView

  • Drop the XpoDataSource component on the Page and specify its TypeName property.

  • Connect XPO to your database server. To do this, handle the Application_Start event in the Global.asax module of your website to create an IDataLayer object. We suggest that you use the ThreadSafeDataLayer in ASP.NET applications.

  • Handle the Web form's Init event to create a Session for the XpoDataSource component. The session must be linked to your DataLayer.

  • We recommend that you create an XPO Session for each request. To do this, create a new session for each page and dispose of it by overriding the Page.Render method.

  • Drop the ASPxGridView control on the Page and bind it to XpoDataSource.

Expanded Results

Run the application. The image below shows the result.

Is this topic helpful?​​​​​​​