Class ColumnAttribute
Configures mapping of mapping class member to database column. Could be applied directly to a property or field or to mapping class/interface. In latter case you should specify member name using MemberName property.
Namespace: LinqToDB.Mapping
Assembly: linq2db.dll
Syntax
public class ColumnAttribute : MappingAttribute
Constructors
| Improve this Doc View SourceColumnAttribute()
Creates attribute instance.
Declaration
public ColumnAttribute()
ColumnAttribute(String)
Creates attribute instance.
Declaration
public ColumnAttribute(string columnName)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnName | Database column name. |
ColumnAttribute(String, String)
Creates attribute instance.
Declaration
public ColumnAttribute(string columnName, string memberName)
Parameters
Type | Name | Description |
---|---|---|
System.String | columnName | Database column name. |
System.String | memberName | Name of mapped member. See MemberName for more details. |
Properties
| Improve this Doc View SourceCanBeNull
Gets or sets whether a column can contain NULL
values.
Declaration
public bool CanBeNull { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Configuration
Gets or sets mapping schema configuration name, for which this attribute should be taken into account.
ProviderName for standard names.
Attributes with null
or empty string Configuration value applied to all configurations (if no attribute found for current configuration).
Declaration
public string? Configuration { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
CreateFormat
Custom template for column definition in create table SQL expression, generated using CreateTable<T>(IDataContext, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, DefaultNullable, Nullable<String>, TableOptions) methods. Template accepts following string parameters:
- {0} - column name;
- {1} - column type;
- {2} - NULL specifier;
- {3} - identity specification.
Declaration
public string? CreateFormat { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
DataType
Gets or sets linq2db type for column. Default value: default type, defined for member type in mapping schema.
Declaration
public DataType DataType { get; set; }
Property Value
Type | Description |
---|---|
DataType |
DbType
Gets or sets the name of the database column type. Default value: default type, defined for member type in mapping schema.
Declaration
public string? DbType { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
IsColumn
Gets or sets flag that tells that current member should be included into mapping.
Use NonColumnAttribute instead as a shorthand.
Default value: true
.
Declaration
public bool IsColumn { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsDiscriminator
Gets or sets whether a column contains a discriminator value for a LINQ to DB inheritance hierarchy.
InheritanceMappingAttribute for more details.
Default value: false
.
Declaration
public bool IsDiscriminator { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsIdentity
Gets or sets whether a column contains values that the database auto-generates. Also see IdentityAttribute.
Declaration
public bool IsIdentity { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPrimaryKey
Gets or sets whether this class member represents a column that is part or all of the primary key of the table. Also see PrimaryKeyAttribute.
Declaration
public bool IsPrimaryKey { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Length
Gets or sets the length of the database column. Default value: value, defined for member type in mapping schema.
Declaration
public int Length { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
MemberName
Gets or sets the name of mapped member. When applied to class or interface, should contain name of property of field.
If column mapped to a property or field of composite object, MemberName should contain a path to that
member using dot as separator.
public class Address
{
public string City { get; set; }
public string Street { get; set; }
public int Building { get; set; }
}
[Column("city", "Residence.City")]
[Column("user_name", "Name")]
public class User
{
public string Name;
[Column("street", ".Street")]
[Column("building_number", MemberName = ".Building")]
public Address Residence { get; set; }
}
Declaration
public string? MemberName { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
Name
Gets or sets the name of a column in database. If not specified, member name will be used.
Declaration
public string? Name { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
Order
Specifies the order of the field in table creation. Positive values first (ascending), then unspecified (arbitrary), then negative values (ascending).
Declaration
public int Order { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Ordering performed in SqlTable constructor.
Precision
Gets or sets the precision of the database column. Default value: value, defined for member type in mapping schema.
Declaration
public int Precision { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
PrimaryKeyOrder
Gets or sets the Primary Key order. See Order for more details.
Declaration
public int PrimaryKeyOrder { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Scale
Gets or sets the Scale of the database column. Default value: value, defined for member type in mapping schema.
Declaration
public int Scale { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
SkipOnEntityFetch
Gets or sets whether a column must be explicitly defined in a Select statement to be fetched. If true
, a "SELECT *"-ish statement won't retrieve this column.
Default value: false
.
Declaration
public bool SkipOnEntityFetch { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SkipOnInsert
Gets or sets whether a column is insertable. This flag will affect only insert operations with implicit columns specification like Insert<T>(IDataContext, T, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions) method and will be ignored when user explicitly specifies value for this column.
Declaration
public bool SkipOnInsert { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SkipOnUpdate
Gets or sets whether a column is updatable. This flag will affect only update operations with implicit columns specification like Update<T>(IDataContext, T, Nullable<String>, Nullable<String>, Nullable<String>, Nullable<String>, TableOptions) method and will be ignored when user explicitly specifies value for this column.
Declaration
public bool SkipOnUpdate { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Storage
Gets or sets a storage property or field to hold the value from a column. Could be usefull e.g. in combination of private storage field and getter-only mapping property.
Declaration
public string? Storage { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.String> |
Methods
| Improve this Doc View SourceGetObjectID()
Declaration
public override string GetObjectID()
Returns
Type | Description |
---|---|
System.String |