Skip to main content
A newer version of this page is available. .

Ways to Add a Business Class

  • 3 minutes to read

This topic describes how to add a business class to your application’s data model.

Code First

You can implement business classes from scratch or import them from external modules.

Implement a Business Class from Scratch

Refer to the following help topics for information on how to implement business model with your ORM:

Import Classes from a Business Class Library or Module

Note

XPO:

When you add a class to the data model, all the referenced classes are also added.

EF Core:

When you add a class to the data model, you should register all the business class’ ancestors and referenced classes.

You can use existing classes from a Business Class Library or module. For this purpose, reference the assembly with these classes in a MySolution.Module project.

Import All Classes from an Assembly (In Code)

using DevExpress.ExpressApp;
//...
public sealed class MySolutionModule : ModuleBase {
    public MySolutionModule() {
        //...
        AdditionalExportedTypes.AddRange(
            ModuleHelper.CollectExportedTypesFromAssembly(
            typeof(MyNamespace.MyModule).Assembly));
    }
}

Import Select Classes from an Assembly (In Code)

using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
//...
public sealed class MySolutionModule : ModuleBase {
    public MySolutionModule() {
        //...
        AdditionalExportedTypes.AddRange(
            new Type[] { typeof(Address), typeof(Note) });
    }
}

Import Classes Using the Module Designer (.NET Framework)

The Module Designer‘s Exported Types section lists all assemblies that contain business classes in the Referenced Assemblies node. To add a class to the UI construction process, right-click the class and select Use Type in Application.

module designer add class

Note

If you add a module to the Designer’s Required Modules section, its business classes are used in the UI construction process and appear in the Application Model. You cannot change this behavior.

To add all the classes from an assembly, select the assembly and press Space.

Modify a Class from a Business Class Library or Module

You can modify a class from a Business Class Library or module in one of the following ways:

Model First (XPO)

You can use the XPO Data Model Designer to build your application data model in a visual designer and generate the code of underlying business classes.

Step-by-step instructions: How to: Create a Business Model in the XPO Data Model Designer.

Database First

If you already have a database with a set of tables, you can generate business classes that correspond to these tables.

Step-by-step instructions:

See Also