Table of Contents

Class ColumnDescriptor

Namespace
LinqToDB.Mapping
Assembly
linq2db.dll

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 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.

hasInheritanceMapping bool

Owning entity included in inheritance mapping.

Properties

CanBeNull

Gets whether a column can contain null values.

public bool CanBeNull { get; }

Property Value

bool

ColumnName

Gets the name of a column in database. If not specified, MemberName value will be used.

public string ColumnName { get; }

Property Value

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.
public string? CreateFormat { get; }

Property Value

string

DataType

Gets LINQ to DB type for column.

public DataType DataType { get; }

Property Value

DataType

DbType

Gets the name of the database column type.

public string? DbType { get; }

Property Value

string

EntityDescriptor

Gets Entity descriptor.

public EntityDescriptor EntityDescriptor { get; }

Property Value

EntityDescriptor

HasInheritanceMapping

Indicates that owning entity included in inheritance mapping.

public bool HasInheritanceMapping { get; }

Property Value

bool

HasValuesToSkipOnInsert

Gets whether the column has specific values that should be skipped on insert.

public bool HasValuesToSkipOnInsert { get; }

Property Value

bool

HasValuesToSkipOnUpdate

Gets whether the column has specific values that should be skipped on update.

public bool HasValuesToSkipOnUpdate { get; }

Property Value

bool

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

bool

IsIdentity

Gets whether a column contains values that the database auto-generates.

public bool IsIdentity { get; }

Property Value

bool

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

bool

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

MappingSchema

MemberAccessor

Gets column mapping member accessor.

public MemberAccessor MemberAccessor { get; }

Property Value

MemberAccessor

MemberInfo

Gets column mapping member (field or property).

public MemberInfo MemberInfo { get; }

Property Value

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; }
     }</code></pre></example>
public string MemberName { get; }

Property Value

string

MemberType

Gets type of column mapping member (field or property).

public Type MemberType { get; }

Property Value

Type

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

int

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

SequenceNameAttribute

SkipModificationFlags

Gets flags for which operation values are skipped.

public SkipModification SkipModificationFlags { get; }

Property Value

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.

public bool SkipOnEntityFetch { get; }

Property Value

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.

public bool SkipOnInsert { get; }

Property Value

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.

public bool SkipOnUpdate { get; }

Property Value

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.

public string? Storage { get; }

Property Value

string

StorageInfo

Gets value storage member (field or property).

public MemberInfo StorageInfo { get; }

Property Value

MemberInfo

StorageType

Gets type of column value storage member (field or property).

public Type StorageType { get; }

Property Value

Type

ValueConverter

Gets value converter for specific column.

public IValueConverter? ValueConverter { get; }

Property Value

IValueConverter

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 MappingSchema

Mapping schema.

getterExpr Expression

Expression which returns value which has to be converted.

dbDataType DbDataType

Database type.

valueConverter IValueConverter

Optional IValueConverter

includingEnum bool

Provides 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 Expression

Expression which returns value which has to be converted.

dbDataType DbDataType

Database type.

includingEnum bool

Provides default enum conversion.

Returns

Expression

Expression with applied conversions.

CalculateDbDataType(MappingSchema, Type)

public static DbDataType CalculateDbDataType(MappingSchema mappingSchema, Type systemType)

Parameters

mappingSchema MappingSchema
systemType Type

Returns

DbDataType

GetConvertedDbDataType()

Returns DbDataType for current column after conversions.

public DbDataType GetConvertedDbDataType()

Returns

DbDataType

GetDbDataType(bool)

Returns DbDataType for current column.

public DbDataType GetDbDataType(bool completeDataType)

Parameters

completeDataType bool

Returns

DbDataType

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

Expression

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 object

Entity 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 object

The object containing the values for the operation.

descriptor EntityDescriptor

EntityDescriptor of the current instance.

flags SkipModification

The flags that specify which operation should be checked.

Returns

bool

true if object contains values that should be skipped.