Skip to main content
.NET Framework 4.5.2+

MediaDataObject Class

The entity used to store media data in the database.

Namespace: DevExpress.Persistent.BaseImpl.EF

Assembly: DevExpress.Persistent.BaseImpl.EFCore.v24.1.dll

Declaration

[MediaDataObject("MediaDataKey", "MediaData", "MediaResource.MediaData")]
[Browsable(false)]
[EditorAlias("ImagePropertyEditor")]
public class MediaDataObject :
    BaseObject,
    INotifyPropertyChanged,
    INotifyPropertyChanging,
    IEmptyCheckable
[MediaDataObject("MediaDataKey", "MediaData", "MediaResource.MediaData")]
[Browsable(false)]
[EditorAlias("ImagePropertyEditor")]
public class MediaDataObject :
    IXafEntityObject,
    INotifyPropertyChanged,
    IObjectSpaceLink,
    IEmptyCheckable

Remarks

You can use the MediaDataObject type to declare a reference property of a business class that is used to store and display an image.

WinForms, Blazor, and ASP.NET Web Forms Image Property Editors are used automatically for properties of the MediaDataObject type.

You can find an example in the BLOB Image Properties in EF Core topic.

MediaDataObject is a container for three values:

  • MediaDataObject.MediaData

    A byte array object that is loaded from a database on demand when required. It is not loaded together with the MediaDataObject itself and may contain any type of media. This property is non-persistent, its value is stored using the MediaResource.MediaData persistent property to provide delayed loading.

  • MediaDataObject.MediaDataKey

    A key value of the string type. This value should not be changed from your code. It is updated automatically when the MediaData byte array is changed and is unique for each MediaDataObject. MediaDataKey is used in a URL of the MediaData loaded by a browser. The URL is generated under the following conditions.

    • MediaDataKey is constant while MediaData is not updated.
    • It is not required to load MediaData when generating the URL.
    • MediaDataKey can be quickly obtained as it is not required to load MediaData every time to calculate the key.
  • MediaDataObject.MediaResource

    The MediaResourceObject object which exposes the MediaData property of the byte array type. The MediaData property of this object is persistent and stores the byte array returned by the MediaDataObject.MediaData property.

Currently, the MediaDataObject property type is completely supported in ASP.NET Web Forms (ASPxImagePropertyEditor) only. The Winforms and Blazor editors (ImagePropertyEditor) support it partially - they use MediaData only, and does not provide caching.

Note

It is not recommend to change the MediaData value by direct database queries. In this instance, the URL will not change, and it will be required to manually refresh the page to see the changes.

Inheritance

Object
BaseObject
MediaDataObject

Inheritance

Object
MediaDataObject
See Also