ColumnAttribute
This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.
Use this attribute to designate a member of a persistent class to represent a column in a database table. You can apply this attribute to any field or property.
The ColumnAttribute type exposes the following members:
- Name - gets the name of the database column.
- AdoType - gets or sets the internal ado type of the database column.
- IsNullable - gets or sets whether a column can contain null values.
-
UpdateCheck - gets or sets how Telerik Data Access approaches the detection of optimistic concurrency conflicts. The following enums are available:
- Always - always use this column for conflict detection.
- Never - never use this column for conflict detection.
- WhenChanged - use this column only when the member has been changed by the application.
- SqlType - gets or sets the type of the database column.
-
Expression - gets or sets whether a column is a computed column in a database.
Currently the Expression property is not supported. If you want to specify that the column is auto-incremented on the server, set the IsBackendCalculated property to True.
-
Behavior - gets or sets the behavior during data access operations on this column. The following enums are available:
- ReadWrite - the type or field allows full access to user data. All CRUD modifications are allowed.
- InsertOnly - the type or field allows only reading and inserting user data. No modifications (update or delete) are allowed.
- ReadOnly - the type or field allows only reading user data. No CUD modifications (create, update or delete) are allowed.
- IsBackendCalculated - gets or sets whether a column contains values that the database auto-generates.
- IsDiscriminator - gets or sets whether a column contains a discriminator value in an inheritance hierarchy.
- IsPrimaryKey - gets or sets whether this class member represents a column that is part of the primary key of the table.
- IsVersion - gets or sets whether the column type of the member is a database timestamp or version number.
- Length - gets or sets the length of the database column.
- Scale - gets or sets the scale of the database column.
- Converter - gets or sets the converter of the database column.
The following example illustrates the ColumnAttribute.
[Column("Ord_id", IsPrimaryKey = true, IsBackendCalculated = true)]
[Storage("orderId")]
public int OrderId
{
get { return orderId; }
set { orderId = value; }
}
<Column("Ord_id", IsPrimaryKey := True, IsBackendCalculated := True), Storage("orderId")>
Public Property OrderId() As Integer
Get
Return orderId
End Get
Set(ByVal value As Integer)
orderId = value
End Set
End Property
Members without the ColumnAttribute attribute are also assumed to be persistent. However, they will be mapped to a column with the same column name. A typical example is when auto-properties are used. In this case specifying StorateAttribute or any other attribute can be avoided. Telerik Data Access will still resolve the member properly.
public int OrderId
{
get;
set;
}
Public Property OrderId() As Integer