Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

SizeAttribute Class

Specifies the maximum number of characters that can be stored in a column which is created to store the data of a property or field.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.1.dll


[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class SizeAttribute :


The current version of XPO only supports size definitions for the persistent properties or fields of string data types. If the SizeAttribute isn’t applied to a member, the size of the database column which the member’s data is stored in is specified by the SizeAttribute.DefaultStringMappingFieldSize value.

Note the SizeAttribute affects only the creation of the database column. If the database column already exists, its size is not changed.


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;

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

    public string Background {
        get { return background; }
        set { SetPropertyValue<string>(nameof(Background), ref background, value); }

The following code snippets (auto-collected from DevExpress Examples) contain references to the SizeAttribute class.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.


See Also