ColumnAttribute

Ecng.Serialization

Specifies column-level metadata for a mapped property. Controls nullability and maximum length for string/binary columns.

Inherits: Attribute

Properties

IsNullable
public bool IsNullable { get; set; }
value = columnAttribute.IsNullable
columnAttribute.IsNullable = value

Gets or sets whether the column allows NULL values. When not explicitly set, nullability is inferred from the CLR type.

IsNullableSet
public bool IsNullableSet { get; }
value = columnAttribute.IsNullableSet

Gets whether IsNullable was explicitly set.

MaxLength
public int MaxLength { get; set; }
value = columnAttribute.MaxLength
columnAttribute.MaxLength = value

Gets or sets the maximum length for string/binary columns. 0 (the default) and Max both map to the dialect-specific unbounded type (NVARCHAR(MAX) / TEXT). Set to a positive integer for a fixed-size column (NVARCHAR(N) / VARCHAR(N)). Applies only to string and byte[] columns.

Precision
public int Precision { get; set; }
value = columnAttribute.Precision
columnAttribute.Precision = value

Gets or sets the numeric precision for decimal/numeric columns, or the fractional-second digits for date/time columns. 0 means use the dialect default.

Scale
public int Scale { get; set; }
value = columnAttribute.Scale
columnAttribute.Scale = value

Gets or sets the numeric scale for decimal/numeric columns. With Precision set, 0 means no digits after the point, as in DECIMAL(p). Without it, 0 means the dialect default and any other value is paired with the dialect's default precision.

Fields

Max
public const int Max
value = ColumnAttribute.Max

Sentinel to request the dialect-specific unbounded string/binary type (NVARCHAR(MAX) on SQL Server, TEXT on PostgreSQL/SQLite). Use when a column is intentionally large — JSON blobs, exception bodies, raw payloads — to make that intent explicit in the entity, instead of leaving MaxLength at its 0 default.