Built-in Business Classes & Interfaces
- 5 minutes to read
The eXpressApp Framework features the Business Class Library with interfaces for XAF modules and the interface implementations for supported ORMs (XPO and EF Core).
The Business Class Library consists of the following assemblies.
|DevExpress.Persistent.BaseImpl.Xpo.v21.2.dll||Contains ready-to-use XPO persistent classes.|
|DevExpress.Persistent.BaseImpl.EF6.v21.2.dll||Contains ready-to-use Entity Framework 6 Code First classes.|
|DevExpress.Persistent.BaseImpl.EFCore.v21.2.dll||Contains ready-to-use Entity Framework Core classes.|
|DevExpress.Persistent.Base.v21.2.dll||Contains interfaces and helper classes used in XAF Additional Modules. Classes implementing these interfaces are available in the DevExpress.Persistent.BaseImpl.* assemblies listed above.|
Interfaces for XAF Modules
Use service interfaces from the DevExpress.Persistent.Base.v21.2.dll assembly to integrate your business classes to XAF modules like Security System.
- How to: Implement a Custom Security System User Based on an Existing Business Class
- How to: Implement Custom Security Objects (Users, Roles, Operation Permissions)
- How to: Store file attachments in the file system instead of the database (XPO)
- Attach Files to Objects (.NET Framework)
- How to: Add a Custom Column to the Reports List
- Display a Tree List using the ITreeNode Interface
- Display a Tree List using the HCategory Class
- How to: Use Notifications with a Custom Business Class (Implement ISupportNotifications)
- Implement Custom Rules
Interface Implementations for Supported ORMs
The Business Class Library allows you to do the following:
- You can use classes from the DevExpress.Persistent.BaseImpl***.21.2.dll assemblies as they are.
- You can extend persistent classes from the DevExpress.Persistent.BaseImpl***.21.2.dll assemblies to add a custom functionality.
- The eXpressApp Framework installation ships with sources of the DevExpress.Persistent.BaseImpl***.21.2.dll assemblies. They are located at %PROGRAMFILES(x86)%\DevExpress 21.2\Components\Sources\DevExpress.Persistent\ by default. You can use the sources as an example when developing your own business class library. In addition, you can modify the sources and recompile this assembly if required.
- The Business Class Library assemblies do not have references to other XAF assemblies. This allows you to use services defined there (like validation, audit trail, etc.) in non-XAF applications.
Use the Business Class Library Customization Module to change the Business Class Library classes’ UI settings.
Business Class Library Customization Module
The Business Class Library Customization module provides UI settings (Application Model differences) for XPO, Entity Framework 6, and Entity Framework Core classes from the Business Class Library. It specifies class icons, List View columns arrangements and Detail View layouts. To apply settings from this module, invoke the Application Designer and drag the BusinessClassLibraryCustomizationModule item from the toolbox to the Required Modules pane.
Settings provided by this module can be overridden via the Model Editor.
You can add modules to your application when you create a new XAF solution using the Solution Wizard. To do this, select modules in the Choose Extra Modules step.
- To add an extra module in code, add it to the XafApplication.Modules or ModuleBase.RequiredModuleTypes list (adding a reference to the module assembly is insufficient).
Recompile the Business Class Library
You can modify and recompile an assembly with ready-to-use XPO, EF 6, or EF Core entities using the steps below.
Run the Visual Studio Command Prompt as an administrator and execute the Sn.exe (Strong Name Tool) utility with the following parameters.
sn -k "%PROGRAMFILES(x86)%\DevExpress 21.2\Components\Sources\DevExpress.Key\StrongKey.snk"
This will create the strong name file (see Strong-Named Assemblies).
Navigate to one of the following folders.
- %PROGRAMFILES(x86)%\DevExpress 21.2\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl - if you use XPO.
- %PROGRAMFILES(x86)%\DevExpress 21.2\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.EF - if you use EF 6.
- %PROGRAMFILES(x86)%\DevExpress 21.2\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.EFCore - if you use EF Core.
Open the DevExpress.Persistent.BaseImpl.csproj, DevExpress.Persistent.BaseImpl.EF.csproj, or DevExpress.Persistent.BaseImpl.EFCore.NetStandard.csproj project in Visual Studio.
- If you use EF, ensure that the EntityFramework.dll assembly is available. The project already includes a reference to this assembly, but you may need to provide the DLL file. You can download it from NuGet, or copy it from the EF Demo project (%PUBLIC%\Documents\DevExpress Demos 21.2\Components\eXpressApp Framework\EFDemoCodeFirstCS\EFDemo.Module\lib\EntityFramework.dll).
- Modify any class from the opened project.
Compile the project by clicking Rebuild in the context menu invoked for the solution. Once this rebuild is successful, the default assembly located in the %PROGRAMFILES(x86)%\DevExpress 21.2\Components\Bin\Framework folder will be replaced with the modified assembly.
- By default, the same path is used for XAF solution references. If you use an alternate path, copy the created DevExpress.Persistent.BaseImpl.Xpo.v21.2.dll or DevExpress.Persistent.BaseImpl.EF6.v21.2.dll assembly to the appropriate location.
- Some XPO-only modules (Audit Trail and Clone Object) have references to the DevExpress.Persistent.BaseImpl.Xpo.v21.2.dll library. If you are using these modules in your application, they must be rebuilt too. Refer to the How to rebuild assemblies from the source code article for details.
Demo Classes for Most Popular Scenarios
The Business Class Library ships with business classes useful in most of the business applications: Person, Address, Organization, PhoneNumber and so on. We use these classes in demos and tutorials. You can also use these classes in your applications as is, or you can derive and extend them.