Skip to main content
.NET 6.0+

FileAttachmentAttribute Class

Applied to business classes that expose a property of the IFileData type. Activates Controllers that manage file attachments for the target business class. Specifies a property that stores a file attachment.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.Persistent.Base.v23.2.dll


[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = true)]
public class FileAttachmentAttribute :


Use this attribute to activate the following Controllers that provide Actions to manage file attachments:

The FileAttachmentAttribute attribute takes a single parameter - the FileAttachmentAttribute.FileDataPropertyName. The parameter specifies the property of a IFileData type to be used by the Controllers listed above. The snippet below illustrate the FileAttachmentAttribute attribute usage.

public class MyFileAttachment : BaseObject {
    public virtual FileData File { get; set; }

public class FileData : BaseObject, IFileData {
    // ...

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

As an alternative to using the FileAttachmentAttribute, you can inherit from the FileAttachmentBase class. It has the FileAttachmentAttribute applied, and exposes the File property to store file attachments.


It is not recommended to use the DataView mode with the FileAttachmentAttribute. In this mode, a separate request to database is made for each focused List View record.


See Also