xpo-devexpress-dot-xpo-0ce07b68.md
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.v25.2.dll
NuGet Package : DevExpress.Xpo
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true)]
public sealed class SizeAttribute :
Attribute
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, Inherited:=True)>
Public NotInheritable Class SizeAttribute
Inherits Attribute
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;
[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); }
}
}
Imports DevExpress.Xpo
Class Customer
Inherits XPObject
Private _FullName As String
Private _Background As String
<Size(128)> _
Public Property FullName() As String
Get
Return _FullName
End Get
Set(ByVal Value As String)
SetPropertyValue(Of String)(NameOf(FullName), _FullName, Value)
End Set
End Property
<Size(SizeAttribute.Unlimited)> _
Public Property Background() As String
Get
Return _Background
End Get
Set(ByVal Value As String)
SetPropertyValue(Of String)(NameOf(Background), _Background, Value)
End Set
End Property
End Class
Object Attribute SizeAttribute
See Also