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

ImageValueConverter.ConvertToStorageType(Object) Method

Converts the persistent property’s value to the specified type.

Namespace: DevExpress.Xpo.Metadata

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public override object ConvertToStorageType(
    object value
)

Parameters

Name Type Description
value Object

An object which represents the value to convert.

Returns

Type Description
Object

An object which represents the converted value. null (Nothing in Visual Basic) if the specified value is a null reference.

Remarks

The ConvertToStorageType method converts the specified value to the type which is specified by the ImageValueConverter.StorageType property. If this method cannot convert the specified object to the destination type, it throws a NotSupportedException exception.

Example

The following example shows how to convert the value of the Image property to an array of bytes when saving it in a data store.

using DevExpress.Xpo;

public class SampleImageClass : XPObject {
    private System.Drawing.Image image;
    public SampleImageClass(Session session) : base(session) {}

    [ValueConverter(typeof(DevExpress.Xpo.Metadata.ImageValueConverter))]
    public System.Drawing.Image Image {
        get { return image; }
        set {
            SetPropertyValue(nameof(Image) , ref image, value);
        }
    }
}
See Also