Class ColumnDescriptor
Stores mapping entity column descriptor.
public class ColumnDescriptor : IColumnChangeDescriptor
- Inheritance
-
ColumnDescriptor
- Implements
- Extension Methods
Constructors
ColumnDescriptor(MappingSchema, EntityDescriptor, ColumnAttribute?, MemberAccessor, bool)
Creates descriptor instance.
public ColumnDescriptor(MappingSchema mappingSchema, EntityDescriptor entityDescriptor, ColumnAttribute? columnAttribute, MemberAccessor memberAccessor, bool hasInheritanceMapping)
Parameters
mappingSchema
MappingSchemaMapping schema, associated with descriptor.
entityDescriptor
EntityDescriptorEntity descriptor.
columnAttribute
ColumnAttributeColumn attribute, from which descriptor data should be extracted.
memberAccessor
MemberAccessorColumn mapping member accessor.
hasInheritanceMapping
boolOwning entity included in inheritance mapping.
Properties
CanBeNull
Gets whether a column can contain null values.
public bool CanBeNull { get; }
Property Value
ColumnName
Gets the name of a column in database. If not specified, MemberName value will be used.
public string ColumnName { get; }
Property Value
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.
public string? CreateFormat { get; }
Property Value
DataType
Gets LINQ to DB type for column.
public DataType DataType { get; }
Property Value
DbType
Gets the name of the database column type.
public string? DbType { get; }
Property Value
EntityDescriptor
Gets Entity descriptor.
public EntityDescriptor EntityDescriptor { get; }
Property Value
HasInheritanceMapping
Indicates that owning entity included in inheritance mapping.
public bool HasInheritanceMapping { get; }
Property Value
HasValuesToSkipOnInsert
Gets whether the column has specific values that should be skipped on insert.
public bool HasValuesToSkipOnInsert { get; }
Property Value
HasValuesToSkipOnUpdate
Gets whether the column has specific values that should be skipped on update.
public bool HasValuesToSkipOnUpdate { get; }
Property Value
IsDiscriminator
Gets whether a column contains a discriminator value for a LINQ to DB inheritance hierarchy.
InheritanceMappingAttribute for more details.
Default value: false
.
public bool IsDiscriminator { get; }
Property Value
IsIdentity
Gets whether a column contains values that the database auto-generates.
public bool IsIdentity { get; }
Property Value
IsPrimaryKey
Gets whether this member represents a column that is part or all of the primary key of the table. Also see PrimaryKeyAttribute.
public bool IsPrimaryKey { get; }
Property Value
Length
Gets the length of the database column.
public int? Length { get; }
Property Value
- int?
MappingSchema
Gets MappingSchema for current ColumnDescriptor.
public MappingSchema MappingSchema { get; }
Property Value
MemberAccessor
Gets column mapping member accessor.
public MemberAccessor MemberAccessor { get; }
Property Value
MemberInfo
Gets column mapping member (field or property).
public MemberInfo MemberInfo { get; }
Property Value
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; }
}</code></pre></example>
public string MemberName { get; }
Property Value
MemberType
Gets type of column mapping member (field or property).
public Type MemberType { get; }
Property Value
Order
Sort order for column list. Positive values first, then unspecified (null), then negative values.
public int? Order { get; }
Property Value
- int?
Precision
Gets the precision of the database column.
public int? Precision { get; }
Property Value
- 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.
public int PrimaryKeyOrder { get; }
Property Value
Scale
Gets the Scale of the database column.
public int? Scale { get; }
Property Value
- int?
SequenceName
Gets sequence name for specified column.
public SequenceNameAttribute? SequenceName { get; }
Property Value
SkipModificationFlags
Gets flags for which operation values are skipped.
public SkipModification SkipModificationFlags { get; }
Property Value
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
.
public bool SkipOnEntityFetch { get; }
Property Value
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.
public bool SkipOnInsert { get; }
Property Value
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.
public bool SkipOnUpdate { get; }
Property Value
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.
public string? Storage { get; }
Property Value
StorageInfo
Gets value storage member (field or property).
public MemberInfo StorageInfo { get; }
Property Value
StorageType
Gets type of column value storage member (field or property).
public Type StorageType { get; }
Property Value
ValueConverter
Gets value converter for specific column.
public IValueConverter? ValueConverter { get; }
Property Value
Methods
ApplyConversions(MappingSchema, Expression, DbDataType, IValueConverter?, bool)
Helper function for applying all needed conversions for converting value to database type.
public static Expression ApplyConversions(MappingSchema mappingSchema, Expression getterExpr, DbDataType dbDataType, IValueConverter? valueConverter, bool includingEnum)
Parameters
mappingSchema
MappingSchemaMapping schema.
getterExpr
ExpressionExpression which returns value which has to be converted.
dbDataType
DbDataTypeDatabase type.
valueConverter
IValueConverterOptional IValueConverter
includingEnum
boolProvides default enum conversion.
Returns
- Expression
Expression with applied conversions.
ApplyConversions(Expression, DbDataType, bool)
Helper function for applying all needed conversions for converting value to database type.
public Expression ApplyConversions(Expression getterExpr, DbDataType dbDataType, bool includingEnum)
Parameters
getterExpr
ExpressionExpression which returns value which has to be converted.
dbDataType
DbDataTypeDatabase type.
includingEnum
boolProvides default enum conversion.
Returns
- Expression
Expression with applied conversions.
CalculateDbDataType(MappingSchema, Type)
public static DbDataType CalculateDbDataType(MappingSchema mappingSchema, Type systemType)
Parameters
mappingSchema
MappingSchemasystemType
Type
Returns
GetConvertedDbDataType()
Returns DbDataType for current column after conversions.
public DbDataType GetConvertedDbDataType()
Returns
GetDbDataType(bool)
Returns DbDataType for current column.
public DbDataType GetDbDataType(bool completeDataType)
Parameters
completeDataType
bool
Returns
GetDbParamLambda()
Returns Lambda for extracting column value, converted to database type or DataParameter, from entity object.
public LambdaExpression GetDbParamLambda()
Returns
- 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.
public LambdaExpression GetDbValueLambda()
Returns
- LambdaExpression
Returns Lambda which extracts member value to database type.
GetDefaultDbParamExpression()
Returns default column value, converted to database type or DataParameter.
public Expression GetDefaultDbParamExpression()
Returns
GetDefaultDbValueExpression()
Returns Lambda for extracting column value, converted to database type, from entity object.
public Expression GetDefaultDbValueExpression()
Returns
- Expression
Returns Lambda which extracts member value to database type.
GetOriginalValueLambda()
Returns Lambda for extracting original column value from entity object.
public LambdaExpression GetOriginalValueLambda()
Returns
- LambdaExpression
Returns Lambda which extracts member value.
GetProviderValue(object)
Extracts column value, converted to database type, from entity object.
public virtual object? GetProviderValue(object obj)
Parameters
obj
objectEntity object to extract column value from.
Returns
- 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.
public virtual bool ShouldSkip(object obj, EntityDescriptor descriptor, SkipModification flags)
Parameters
obj
objectThe object containing the values for the operation.
descriptor
EntityDescriptorEntityDescriptor of the current instance.
flags
SkipModificationThe flags that specify which operation should be checked.
Returns
- bool
true
if object contains values that should be skipped.