Back to Devexpress

FileAttachmentAttribute Class

expressappframework-devexpress-dot-persistent-dot-base-1b7fb94e.md

latest3.7 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Persistent.Base

Declaration

csharp
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = true)]
public class FileAttachmentAttribute :
    Attribute
vb
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=True)>
Public Class FileAttachmentAttribute
    Inherits Attribute

Remarks

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.

csharp
[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.
csharp
[FileAttachmentAttribute(nameof(File))]
public class MyFileAttachment : BaseObject {
    // ...
    private FileData file;
    public FileData File {
        get { return file; }
        set { SetPropertyValue(nameof(File), ref file, value); }
    }
}
public class FileData : BaseObject, IFileData {
   // ...
}

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.

Inheritance

Object Attribute FileAttachmentAttribute

See Also

FileAttachmentAttribute Members

FileTypeFilterAttribute

DevExpress.Persistent.Base Namespace