Skip to main content

XPMemberInfo.MappingFieldSize Property

Gets the maximum number of characters that can be stored in a field which the member is mapped to.

Namespace: DevExpress.Xpo.Metadata

Assembly: DevExpress.Xpo.v24.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public int MappingFieldSize { get; }

Property Value

Type Description
Int32

An integer value which specifies the maximum number of characters that can be stored. 0 if the type in which the member’s value is saved to a data store isn’t a string.

Remarks

To specify the size of the mapping field, the SizeAttribute must be applied to a property or a field. Otherwise, if this attribute isn’t applied, the default size is specified which equals to 100.

Example

The following example applies the SizeAttribute to the FullName and Background properties. The maximum number of characters that can be stored in a database column which the FullName property is mapped to is 128. As for the Background property the unlimited size of the column it is mapped to is specified.

using DevExpress.Xpo;

class Customer : XPObject {
    private string fullName;
    private string background;

    [Size(128)]
    public string FullName {
        get { return fullName; }
        set { SetPropertyValue<string>(nameof(FullName), ref fullName, value); }
    }

    [Size(SizeAttribute.Unlimited)]
    public string Background {
        get { return background; }
        set { SetPropertyValue<string>(nameof(Background), ref background, value); }
    }
}
See Also