Skip to main content

SizeAttribute Class

Specifies the size of a table column to which a string or BLOB data field/property of an entity class is mapped.

Declaration

SizeAttribute = class(
    TCustomAttribute
)

Remarks

The default size is determined based on the field’s/property’s data type and is specific to the database within which a session component creates the entity model’s schema. String columns are limited to 100 characters (as specified by the TdxSQLConnectionProvider.DefaultStringSize class variable, which you can adjust as required). You can customize the default column size by passing a new size as the SizeAttribute‘s parameter.

Parameter values are treated as follows:

  • 0 or no value. The default size is used (as described above);

  • A negative value or a value exceeding the maximum size allowed for variable character column types (such as varchar or nvarchar) in the connected database. A column size sufficient for storing Memo or BLOB data is used. This is equivalent to applying the BlobAttribute this field/property;

  • The specified size is used.

The following code uses the SizeAttribute to limit the Name column mapped to the FName field to 40 characters.

uses
  ..., dxEMF.Core, dxEMF.Attributes;
type
  [Entity]
  [Automapping]
  TPerson = class
  strict private
    FId: Integer;
    [Size(40)]
    FName: string;
  public
    // ...
  end;

Inheritance

See Also