Class ColumnDescriptor
Stores mapping entity column descriptor.
Implements
Namespace: LinqToDB.Mapping
Assembly: linq2db.dll
Syntax
public class ColumnDescriptor : IColumnChangeDescriptor
Constructors
| Improve this Doc View SourceColumnDescriptor(MappingSchema, EntityDescriptor, ColumnAttribute?, MemberAccessor, bool)
Creates descriptor instance.
Declaration
public ColumnDescriptor(MappingSchema mappingSchema, EntityDescriptor entityDescriptor, ColumnAttribute? columnAttribute, MemberAccessor memberAccessor, bool hasInheritanceMapping)
Parameters
Type | Name | Description |
---|---|---|
MappingSchema | mappingSchema | Mapping schema, associated with descriptor. |
EntityDescriptor | entityDescriptor | Entity descriptor. |
ColumnAttribute | columnAttribute | Column attribute, from which descriptor data should be extracted. |
MemberAccessor | memberAccessor | Column mapping member accessor. |
bool | hasInheritanceMapping | Owning entity included in inheritance mapping. |
Properties
| Improve this Doc View SourceCanBeNull
Gets whether a column can contain null values.
Declaration
public bool CanBeNull { get; }
Property Value
Type | Description |
---|---|
bool |
ColumnName
Gets the name of a column in database. If not specified, MemberName value will be used.
Declaration
public string ColumnName { get; }
Property Value
Type | Description |
---|---|
string |
CreateFormat
Custom template for column definition in create table SQL expression, generated using CreateTable<T>(IDataContext, string?, string?, string?, string?, string?, DefaultNullable, 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; }
Property Value
Type | Description |
---|---|
string |
DataType
Gets LINQ to DB type for column.
Declaration
public DataType DataType { get; }
Property Value
Type | Description |
---|---|
DataType |
DbType
Gets the name of the database column type.
Declaration
public string? DbType { get; }
Property Value
Type | Description |
---|---|
string |
EntityDescriptor
Gets Entity descriptor.
Declaration
public EntityDescriptor EntityDescriptor { get; }
Property Value
Type | Description |
---|---|
EntityDescriptor |
HasInheritanceMapping
Indicates that owning entity included in inheritance mapping.
Declaration
public bool HasInheritanceMapping { get; }
Property Value
Type | Description |
---|---|
bool |
HasValuesToSkipOnInsert
Gets whether the column has specific values that should be skipped on insert.
Declaration
public bool HasValuesToSkipOnInsert { get; }
Property Value
Type | Description |
---|---|
bool |
HasValuesToSkipOnUpdate
Gets whether the column has specific values that should be skipped on update.
Declaration
public bool HasValuesToSkipOnUpdate { get; }
Property Value
Type | Description |
---|---|
bool |
IsDiscriminator
Gets 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; }
Property Value
Type | Description |
---|---|
bool |
IsIdentity
Gets whether a column contains values that the database auto-generates.
Declaration
public bool IsIdentity { get; }
Property Value
Type | Description |
---|---|
bool |
IsPrimaryKey
Gets whether this member represents a column that is part or all of the primary key of the table. Also see PrimaryKeyAttribute.
Declaration
public bool IsPrimaryKey { get; }
Property Value
Type | Description |
---|---|
bool |
Length
Gets the length of the database column.
Declaration
public int? Length { get; }
Property Value
Type | Description |
---|---|
int? |
MappingSchema
Gets MappingSchema for current ColumnDescriptor.
Declaration
public MappingSchema MappingSchema { get; }
Property Value
Type | Description |
---|---|
MappingSchema |
MemberAccessor
Gets column mapping member accessor.
Declaration
public MemberAccessor MemberAccessor { get; }
Property Value
Type | Description |
---|---|
MemberAccessor |
MemberInfo
Gets column mapping member (field or property).
Declaration
public MemberInfo MemberInfo { get; }
Property Value
Type | Description |
---|---|
MemberInfo |
MemberName
Gets the name of mapped member. When applied to class or interface, should contain name of property of field.
If column is 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.Street")]
[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; }
Property Value
Type | Description |
---|---|
string |
MemberType
Gets type of column mapping member (field or property).
Declaration
public Type MemberType { get; }
Property Value
Type | Description |
---|---|
Type |
Order
Sort order for column list. Positive values first, then unspecified (null), then negative values.
Declaration
public int? Order { get; }
Property Value
Type | Description |
---|---|
int? |
Precision
Gets the precision of the database column.
Declaration
public int? Precision { get; }
Property Value
Type | Description |
---|---|
int? |
PrimaryKeyOrder
Gets order of current column in composite primary key. Order is used for query generation to define in which order primary key columns must be mentioned in query from columns with smallest order value to greatest.
Declaration
public int PrimaryKeyOrder { get; }
Property Value
Type | Description |
---|---|
int |
Scale
Gets the Scale of the database column.
Declaration
public int? Scale { get; }
Property Value
Type | Description |
---|---|
int? |
SequenceName
Gets sequence name for specified column.
Declaration
public SequenceNameAttribute? SequenceName { get; }
Property Value
Type | Description |
---|---|
SequenceNameAttribute |
SkipModificationFlags
Gets flags for which operation values are skipped.
Declaration
public SkipModification SkipModificationFlags { get; }
Property Value
Type | Description |
---|---|
SkipModification |
SkipOnEntityFetch
Gets 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; }
Property Value
Type | Description |
---|---|
bool |
SkipOnInsert
Gets whether a column is insertable. This flag will affect only insert operations with implicit columns specification like Insert<T>(IDataContext, T, string?, string?, string?, string?, TableOptions) method and will be ignored when user explicitly specifies value for this column.
Declaration
public bool SkipOnInsert { get; }
Property Value
Type | Description |
---|---|
bool |
SkipOnUpdate
Gets whether a column is updatable. This flag will affect only update operations with implicit columns specification like Update<T>(IDataContext, T, string?, string?, string?, string?, TableOptions) method and will be ignored when user explicitly specifies value for this column.
Declaration
public bool SkipOnUpdate { get; }
Property Value
Type | Description |
---|---|
bool |
Storage
Gets 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; }
Property Value
Type | Description |
---|---|
string |
StorageInfo
Gets value storage member (field or property).
Declaration
public MemberInfo StorageInfo { get; }
Property Value
Type | Description |
---|---|
MemberInfo |
StorageType
Gets type of column value storage member (field or property).
Declaration
public Type StorageType { get; }
Property Value
Type | Description |
---|---|
Type |
ValueConverter
Gets value converter for specific column.
Declaration
public IValueConverter? ValueConverter { get; }
Property Value
Type | Description |
---|---|
IValueConverter |
Methods
| Improve this Doc View SourceApplyConversions(MappingSchema, Expression, DbDataType, IValueConverter?, bool)
Helper function for applying all needed conversions for converting value to database type.
Declaration
public static Expression ApplyConversions(MappingSchema mappingSchema, Expression getterExpr, DbDataType dbDataType, IValueConverter? valueConverter, bool includingEnum)
Parameters
Type | Name | Description |
---|---|---|
MappingSchema | mappingSchema | Mapping schema. |
Expression | getterExpr | Expression which returns value which has to be converted. |
DbDataType | dbDataType | Database type. |
IValueConverter | valueConverter | Optional IValueConverter |
bool | includingEnum | Provides default enum conversion. |
Returns
Type | Description |
---|---|
Expression | Expression with applied conversions. |
ApplyConversions(Expression, DbDataType, bool)
Helper function for applying all needed conversions for converting value to database type.
Declaration
public Expression ApplyConversions(Expression getterExpr, DbDataType dbDataType, bool includingEnum)
Parameters
Type | Name | Description |
---|---|---|
Expression | getterExpr | Expression which returns value which has to be converted. |
DbDataType | dbDataType | Database type. |
bool | includingEnum | Provides default enum conversion. |
Returns
Type | Description |
---|---|
Expression | Expression with applied conversions. |
CalculateDbDataType(MappingSchema, Type)
Declaration
public static DbDataType CalculateDbDataType(MappingSchema mappingSchema, Type systemType)
Parameters
Type | Name | Description |
---|---|---|
MappingSchema | mappingSchema | |
Type | systemType |
Returns
Type | Description |
---|---|
DbDataType |
GetConvertedDbDataType()
Returns DbDataType for current column after conversions.
Declaration
public DbDataType GetConvertedDbDataType()
Returns
Type | Description |
---|---|
DbDataType |
GetDbDataType(bool)
Returns DbDataType for current column.
Declaration
public DbDataType GetDbDataType(bool completeDataType)
Parameters
Type | Name | Description |
---|---|---|
bool | completeDataType |
Returns
Type | Description |
---|---|
DbDataType |
GetDbParamLambda()
Returns Lambda for extracting column value, converted to database type or DataParameter, from entity object.
Declaration
public LambdaExpression GetDbParamLambda()
Returns
Type | Description |
---|---|
LambdaExpression | Returns Lambda which extracts member value to database type or DataParameter. |
GetDbValueLambda()
Returns Lambda for extracting column value, converted to database type, from entity object.
Declaration
public LambdaExpression GetDbValueLambda()
Returns
Type | Description |
---|---|
LambdaExpression | Returns Lambda which extracts member value to database type. |
GetDefaultDbParamExpression()
Returns default column value, converted to database type or DataParameter.
Declaration
public Expression GetDefaultDbParamExpression()
Returns
Type | Description |
---|---|
Expression |
GetDefaultDbValueExpression()
Returns Lambda for extracting column value, converted to database type, from entity object.
Declaration
public Expression GetDefaultDbValueExpression()
Returns
Type | Description |
---|---|
Expression | Returns Lambda which extracts member value to database type. |
GetOriginalValueLambda()
Returns Lambda for extracting original column value from entity object.
Declaration
public LambdaExpression GetOriginalValueLambda()
Returns
Type | Description |
---|---|
LambdaExpression | Returns Lambda which extracts member value. |
GetProviderValue(object)
Extracts column value, converted to database type, from entity object.
Declaration
public virtual object? GetProviderValue(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | Entity object to extract column value from. |
Returns
Type | Description |
---|---|
object | Returns column value, converted to database type. |
ShouldSkip(object, EntityDescriptor, SkipModification)
Checks if the passed object has values that should bes skipped based on the given flags.
Declaration
public virtual bool ShouldSkip(object obj, EntityDescriptor descriptor, SkipModification flags)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object containing the values for the operation. |
EntityDescriptor | descriptor | EntityDescriptor of the current instance. |
SkipModification | flags | The flags that specify which operation should be checked. |
Returns
Type | Description |
---|---|
bool |
|