The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

NullValueAttribute Class

Associates a constant with the null value of a property or a field of a simple type.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.1.dll

Declaration

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class NullValueAttribute : Attribute
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, Inherited:=True)>
Public NotInheritable Class NullValueAttribute
    Inherits Attribute
    Implements
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class NullValueAttribute : Attribute
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, Inherited:=True)>
Public NotInheritable Class NullValueAttribute
    Inherits Attribute
    Implements

Remarks

The NullValueAttribute is provided for compatibility with .NET Framework 1.x which doesn't have support for nullable types. The NullValueAttribute allows null values to be stored in a database and displayed in a UI. Whenever XPO stores a property or a field value to a database or supplies it to a data-bound control, the value is compared with the constant associated with a null value. If they are equal, null (Nothing in VB) is returned for the property or field instead of the associated value. Similarly, when the property's value is retrieved from the database or the data-bound control, it is compared with a null value. If these values are equal, the NullValueAttribute.Value is returned.


public class Example : XPObject {
    [NullValue(Int32.MinValue)]
    public int NullOnMinValueFieldInt;
    [NullValue(0)]
    public int NullOnZeroFieldInt;
    [NullValue("")]
    public string NullOnEmptyStringFieldString;
    [NullValue("NULL")]
    public string NullOnNULLFieldString;
}

Note that nullable types are supported by XPO under .NET Framework 2.0 and later.

Inheritance

Object
Attribute
NullValueAttribute

Implements

See Also