Class Column
Represents a column in a database table with metadata and attributes that provide detailed information about its configuration and behavior within the schema.
public class Column : SchemaItem, IVisitorAcceptor, IDataItem, ICheckable
- Inheritance
-
Column
- Implements
- Inherited Members
Remarks
The Column class captures information such as the type, size, precision, scale,
attributes, and constraints of a database column. It includes properties that
reflect specialized characteristics such as being a primary key, foreign key,
computed column, or identity column. Additionally, it supports methods to manage
its attributes or configure it as an identity column.
Constructors
Column(Table, string, ColumnType, string, short, byte, byte, ColumnAttributes, object, string)
Represents a column in a database table with metadata and attributes that provide detailed information about its configuration and behavior within the schema.
public Column(Table table, string name, ColumnType type, string nativeType, short size, byte precision, byte scale, ColumnAttributes attributes, object defaultValue, string description)
Parameters
tableTableThe table to which this column belongs.
namestringThe name of the column within the table.
typeColumnTypeThe logical type of the column, defined by
ColumnType.nativeTypestringThe database-specific type of the column as a string.
sizeshortThe maximum size of the column's data in bytes or characters.
precisionbyteThe precision of the column, primarily used for numeric types.
scalebyteThe scale (number of decimal places) of numeric types.
attributesColumnAttributesThe attributes that describe the column's behavior and constraints.
defaultValueobjectThe default value defined for the column if no value is provided during insertion.
descriptionstringThe description or documentation of the column, often used for metadata purposes.
Remarks
The Column class captures information such as the type, size, precision, scale,
attributes, and constraints of a database column. It includes properties that
reflect specialized characteristics such as being a primary key, foreign key,
computed column, or identity column. Additionally, it supports methods to manage
its attributes or configure it as an identity column.
Properties
Attributes
Gets the attributes that describe the column's behavior and constraints.'
public ColumnAttributes Attributes { get; }
Property Value
ColumnType
Gets the type of the column, which is defined by the ColumnType enumeration.
public ColumnType ColumnType { get; }
Property Value
DataType
Gets the definition of the column's data type if it's user-defined and available in imported schema.
public DataType DataType { get; }
Property Value
DefaultValue
Gets the default value defined for the column if no value is provided during insertion.
public object DefaultValue { get; }
Property Value
Description
Gets the description or documentation of the column, often used for metadata purposes.
public string Description { get; }
Property Value
IdentityIncrement
Gets or sets the increment value for the identity column.
public long IdentityIncrement { get; }
Property Value
IdentitySeed
Gets or sets the seed value for the identity column.
public long IdentitySeed { get; }
Property Value
IsAlphabetic
Gets a value indicating whether the column is of an alphabetic type.
public bool IsAlphabetic { get; }
Property Value
IsBinary
Gets a value indicating whether the column is of a binary type.
public bool IsBinary { get; }
Property Value
IsChecked
Gets or sets a value indicating whether the item is checked.
public bool IsChecked { get; set; }
Property Value
IsComputed
Gets a value indicating whether the column is a computed column.
public bool IsComputed { get; }
Property Value
IsFKColumn
Gets a value indicating whether the column is a foreign key column.
public bool IsFKColumn { get; }
Property Value
IsFixedLength
Gets a value indicating whether the column is fixed-length.
public bool IsFixedLength { get; }
Property Value
IsGenerated
Gets a value indicating whether the column is a row version column.
public bool IsGenerated { get; }
Property Value
IsIdentity
Gets a value indicating whether the column is an identity column.
public bool IsIdentity { get; }
Property Value
IsIndexColumn
Gets a value indicating whether the column is an index column.
public bool IsIndexColumn { get; }
Property Value
IsIntegral
Gets a value indicating whether the column is of an integral type.
public bool IsIntegral { get; }
Property Value
IsKeyColumn
Gets a value indicating whether the column is a key column.
public bool IsKeyColumn { get; }
Property Value
IsNatural
Gets a value indicating whether the column is of a natural integer type, i.e., an unsigned integer
public bool IsNatural { get; }
Property Value
IsNumeric
Gets a value indicating whether the column is of a numeric type.
public bool IsNumeric { get; }
Property Value
IsPKColumn
Gets a value indicating whether the column is a primary key column.
public bool IsPKColumn { get; }
Property Value
IsRequired
Gets a value indicating whether the column is nullable.
public bool IsRequired { get; }
Property Value
IsTemporal
Gets a value indicating whether the column is of a temporal type.
public bool IsTemporal { get; }
Property Value
IsUnicode
Gets a value indicating whether the column is of a Unicode type.
public bool IsUnicode { get; }
Property Value
IsUnsigned
Gets a value indicating whether the column is of an unsigned integer type.
public bool IsUnsigned { get; }
Property Value
NativeType
Gets the native type of the column as a string.
public string NativeType { get; }
Property Value
Precision
Gets the precision of the column, primarily used for numeric types.
public byte Precision { get; }
Property Value
Scale
Gets the scale (number of decimal places) of numeric types.
public byte Scale { get; }
Property Value
Size
Gets the size (or character length) of the column's data.'
public short Size { get; }
Property Value
Table
Gets the table to which this column belongs.
public Table Table { get; }
Property Value
Methods
AcceptVisitor(IVisitor)
Accepts a visitor, allowing it to perform operations on the implementing class. The visitor will typically have specific methods for handling different types of elements in the object structure.
public override void AcceptVisitor(IVisitor visitor)
Parameters
visitorIVisitorThe visitor instance that will perform operations on the implementing class.
MakeIdentity(long, long)
Configures the column as an identity column with a specified seed and increment.
public void MakeIdentity(long seed, long increment)
Parameters
seedlongThe initial value of the identity column.
incrementlongThe step value used to increment the identity column.
SetAttribute(ColumnAttributes)
Sets the attribute of the column.
public void SetAttribute(ColumnAttributes attribute)
Parameters
attributeColumnAttributesThe attribute to set.