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

How to: Implement File Data Properties

  • 4 minutes to read

This topic demonstrates how to implement a business class with a file data property and a file collection property. For this purpose, the Resume class, which is used to store and manage an employee’s resume information, is implemented. It has three properties: File, Contact and Portfolio. The File property provides a file, the Contact property contains a reference to the Contact class, and the Portfolio property returns a collection of the employee’s files.

To add a file data type property and a file collection property to a business object, you should use a type that implements the IFileData interface and one that applies the FileAttachment attribute. In this instance, the FileAttachmentsWindowsFormsModule, FileAttachmentsAspNetModule, or FileAttachmentsBlazorModule modules should be added to your WinForms, ASP.NET Web, or Blazor module projects respectively. These modules contain Property Editors for IFileData type properties, and Controllers with Actions that are necessary for file manipulation. For details, refer to the File Attachments Module Overview topic.

To add the FileAttachmentsWindowsFormsModule or FileAttachmentsAspNetModule module(s) to a .NET Framework application, invoke the Module Designer for the WinForms or ASP.NET module project(s), drag the corresponding item from the Toolbox to the Designer’s Required Modules section, and rebuild the solution.

To add the FileAttachmentsWindowsFormsModule or FileAttachmentsBlazorModule module(s) to a .NET Core application, install the DevExpress.WindowsDesktop.XAF.FileAttachment.Win or DevExpress.ExpressApp.FileAttachment.Blazor NuGet packages to the WinForms or Blazor module project(s). Add the File Attachment Module to the platform-specific module’s RequiredModuleTypes collection. (For more information, refer to the Reuse Implemented Functionality topic.) Rebuild the solution.

The following code demonstrates a Resume business object.

public class Resume : BaseObject {
   public Resume(Session session) : base(session) {}
   private FileData file;
   [Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never)]
   public FileData File {
      get { return file; }
      set {
         SetPropertyValue(nameof(File), ref file, value);
  [Aggregated, Association("Resume-PortfolioFileData")]
  public XPCollection<PortfolioFileData> Portfolio {
     get { return GetCollection<PortfolioFileData>(nameof(Portfolio)); }
public class PortfolioFileData : FileAttachmentBase {
   public PortfolioFileData(Session session) : base(session) {}
   private DocumentType documentType;
   protected Resume resume;
   [Persistent, Association("Resume-PortfolioFileData")]
   public Resume Resume {
      get { return resume; }
      set { 
         SetPropertyValue(nameof(Resume), ref resume, value); 
   public override void AfterConstruction() {
      documentType = DocumentType.Unknown;
   public DocumentType DocumentType {
      get { return documentType; }
      set { SetPropertyValue(nameof(DocumentType), ref documentType, value);}
public enum DocumentType { SourceCode = 1, Tests = 2, Documentation = 3, 
   Diagrams = 4, ScreenShots = 5, Unknown = 6 };

To create a collection of an employee’s files, the Resume class has the Portfolio property of the XPCollection<PortfolioFileData> type. The PortfolioFileData class is inherited from the FileAttachmentBase class, which in turn, uses the FileAttachment interface. The FileAttachmentBase class and the FileAttachment attribute are the parts of the Business Objects Library.

The PortfolioFileData class has the DocumentType property that specifies the portfolio file type. This property is initialized in the AfterConstruction method override. The PortfolioFileData class also stores a reference to a Resume object in its Resume property.

The following images show the Resume Detail View in WinForms, ASP.NET Web, and Blazor applications.




See Also