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.v24.2.dll
NuGet Package: DevExpress.Persistent.Base
Declaration
Remarks
Use this attribute to activate the following Controllers that provide Actions to manage file attachments:
- FileAttachmentController (ASP.NET Web Forms)
- FileAttachmentController (Windows Forms)
- FileAttachmentListViewController (Windows Forms)
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.
[FileAttachmentAttribute(nameof(File))]
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.
Note
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.