Class PropertyMappingBuilder<TEntity, TProperty>
Column or association fluent mapping builder.
public class PropertyMappingBuilder<TEntity, TProperty>
Type Parameters
TEntityEntity type.
TPropertyColumn or association member type.
- Inheritance
-
PropertyMappingBuilder<TEntity, TProperty>
- Extension Methods
Constructors
PropertyMappingBuilder(EntityMappingBuilder<TEntity>, Expression<Func<TEntity, TProperty>>)
Creates column or association fluent mapping builder.
public PropertyMappingBuilder(EntityMappingBuilder<TEntity> entity, Expression<Func<TEntity, TProperty>> memberGetter)
Parameters
entityEntityMappingBuilder<TEntity>Entity fluent mapping builder.
memberGetterExpression<Func<TEntity, TProperty>>Column or association member getter expression.
Methods
Association<TOther>(Expression<Func<TEntity, IEnumerable<TOther>>>, Expression<Func<TEntity, IDataContext, IQueryable<TOther>>>, bool?)
Adds association mapping to current column's entity.
public PropertyMappingBuilder<TEntity, IEnumerable<TOther>> Association<TOther>(Expression<Func<TEntity, IEnumerable<TOther>>> prop, Expression<Func<TEntity, IDataContext, IQueryable<TOther>>> queryExpression, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, IEnumerable<TOther>>>Association member getter expression.
queryExpressionExpression<Func<TEntity, IDataContext, IQueryable<TOther>>>Query expression.
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, IEnumerable<TOther>>
Returns fluent property mapping builder.
Type Parameters
TOtherOther association side type
Association<TOther>(Expression<Func<TEntity, IEnumerable<TOther>>>, Expression<Func<TEntity, TOther, bool>>, bool?)
Adds association mapping to current column's entity.
public PropertyMappingBuilder<TEntity, IEnumerable<TOther>> Association<TOther>(Expression<Func<TEntity, IEnumerable<TOther>>> prop, Expression<Func<TEntity, TOther, bool>> predicate, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, IEnumerable<TOther>>>Association member getter expression.
predicateExpression<Func<TEntity, TOther, bool>>Predicate expression.
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, IEnumerable<TOther>>
Returns fluent property mapping builder.
Type Parameters
TOtherOther association side type
Association<TOther>(Expression<Func<TEntity, TOther>>, Expression<Func<TEntity, IDataContext, IQueryable<TOther>>>, bool?)
Adds association mapping to current column's entity.
public PropertyMappingBuilder<TEntity, TOther> Association<TOther>(Expression<Func<TEntity, TOther>> prop, Expression<Func<TEntity, IDataContext, IQueryable<TOther>>> queryExpression, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, TOther>>Association member getter expression.
queryExpressionExpression<Func<TEntity, IDataContext, IQueryable<TOther>>>Query expression.
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TOther>
Returns fluent property mapping builder.
Type Parameters
TOtherOther association side type
Association<TOther>(Expression<Func<TEntity, TOther>>, Expression<Func<TEntity, TOther, bool>>, bool?)
Adds association mapping to current column's entity.
public PropertyMappingBuilder<TEntity, TOther> Association<TOther>(Expression<Func<TEntity, TOther>> prop, Expression<Func<TEntity, TOther, bool>> predicate, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, TOther>>Association member getter expression.
predicateExpression<Func<TEntity, TOther, bool>>Predicate expression
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TOther>
Returns fluent property mapping builder.
Type Parameters
TOtherOther association side type
Association<TPropElement, TThisKey, TOtherKey>(Expression<Func<TEntity, IEnumerable<TPropElement>>>, Expression<Func<TEntity, TThisKey>>, Expression<Func<TPropElement, TOtherKey>>, bool?)
Adds association mapping to current column's entity.
public PropertyMappingBuilder<TEntity, IEnumerable<TPropElement>> Association<TPropElement, TThisKey, TOtherKey>(Expression<Func<TEntity, IEnumerable<TPropElement>>> prop, Expression<Func<TEntity, TThisKey>> thisKey, Expression<Func<TPropElement, TOtherKey>> otherKey, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, IEnumerable<TPropElement>>>Association member getter expression.
thisKeyExpression<Func<TEntity, TThisKey>>This association key getter expression.
otherKeyExpression<Func<TPropElement, TOtherKey>>Other association key getter expression.
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, IEnumerable<TPropElement>>
Returns fluent property mapping builder.
Type Parameters
TPropElementAssociation member type.
TThisKeyThis association side key type.
TOtherKeyOther association side key type.
Association<TOther, TThisKey, TOtherKey>(Expression<Func<TEntity, TOther>>, Expression<Func<TEntity, TThisKey>>, Expression<Func<TOther, TOtherKey>>, bool?)
Adds association mapping to current column's entity.
public PropertyMappingBuilder<TEntity, TOther> Association<TOther, TThisKey, TOtherKey>(Expression<Func<TEntity, TOther>> prop, Expression<Func<TEntity, TThisKey>> thisKey, Expression<Func<TOther, TOtherKey>> otherKey, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, TOther>>Association member getter expression.
thisKeyExpression<Func<TEntity, TThisKey>>This association key getter expression.
otherKeyExpression<Func<TOther, TOtherKey>>Other association key getter expression.
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TOther>
Returns association mapping builder.
Type Parameters
TOtherAssociation member type.
TThisKeyThis association side key type.
TOtherKeyOther association side key type.
Build()
Adds configured mappings to builder's mapping schema.
public FluentMappingBuilder Build()
Returns
Entity<TE>(string?)
Creates entity builder for specified mapping type.
public EntityMappingBuilder<TE> Entity<TE>(string? configuration = null)
Parameters
configurationstringOptional mapping schema configuration name, for which this entity builder should be taken into account. ProviderName for standard configuration names.
Returns
- EntityMappingBuilder<TE>
Returns entity mapping builder.
Type Parameters
TEMapping type.
HasAttribute(MappingAttribute)
Adds attribute to current mapping member.
public PropertyMappingBuilder<TEntity, TProperty> HasAttribute(MappingAttribute attribute)
Parameters
attributeMappingAttributeMapping attribute to add to specified member.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column or association mapping builder.
HasColumnName(string)
Sets name for current column.
public PropertyMappingBuilder<TEntity, TProperty> HasColumnName(string columnName)
Parameters
columnNamestringColumn name.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasConversionFunc<TProvider>(Func<TProperty, TProvider>, Func<TProvider, TProperty>, bool)
Configures the property so that the property value is converted to the given type before writing to the database and converted back when reading from the database.
public PropertyMappingBuilder<TEntity, TProperty> HasConversionFunc<TProvider>(Func<TProperty, TProvider> toProvider, Func<TProvider, TProperty> toModel, bool handlesNulls = false)
Parameters
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
Type Parameters
TProviderThe type to convert to and from.
HasConversion<TProvider>(Expression<Func<TProperty, TProvider>>, Expression<Func<TProvider, TProperty>>, bool)
Configures the property so that the property value is converted to the given type before writing to the database and converted back when reading from the database.
public PropertyMappingBuilder<TEntity, TProperty> HasConversion<TProvider>(Expression<Func<TProperty, TProvider>> toProvider, Expression<Func<TProvider, TProperty>> toModel, bool handlesNulls = false)
Parameters
toProviderExpression<Func<TProperty, TProvider>>toModelExpression<Func<TProvider, TProperty>>handlesNullsbool
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
Type Parameters
TProviderThe type to convert to and from.
HasCreateFormat(string)
Sets custom column create SQL template.
public PropertyMappingBuilder<TEntity, TProperty> HasCreateFormat(string format)
Parameters
formatstringCustom 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.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasDataType(DataType)
Sets LINQ to DB type for current column.
public PropertyMappingBuilder<TEntity, TProperty> HasDataType(DataType dataType)
Parameters
dataTypeDataTypeData type.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasDbType(string)
Sets database type for current column.
public PropertyMappingBuilder<TEntity, TProperty> HasDbType(string dbType)
Parameters
dbTypestringColumn type.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasLength(int)
Sets the length of the database column.
public PropertyMappingBuilder<TEntity, TProperty> HasLength(int length)
Parameters
lengthintColumn length.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasOrder(int)
Sets the Order of the database column.
public PropertyMappingBuilder<TEntity, TProperty> HasOrder(int order)
Parameters
orderintColumn order.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasPrecision(int)
Sets the precision of the database column.
public PropertyMappingBuilder<TEntity, TProperty> HasPrecision(int precision)
Parameters
precisionintColumn precision.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasScale(int)
Sets the Scale of the database column.
public PropertyMappingBuilder<TEntity, TProperty> HasScale(int scale)
Parameters
scaleintColumn scale.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasSkipOnInsert(bool)
Sets 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 PropertyMappingBuilder<TEntity, TProperty> HasSkipOnInsert(bool skipOnInsert = true)
Parameters
skipOnInsertboolIf
true- column will be ignored for implicit insert operations.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasSkipOnUpdate(bool)
Sets 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 PropertyMappingBuilder<TEntity, TProperty> HasSkipOnUpdate(bool skipOnUpdate = true)
Parameters
skipOnUpdateboolIf
true- column will be ignored for implicit update operations.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
HasStorage(string)
Adds data storage property or field for current column.
public PropertyMappingBuilder<TEntity, TProperty> HasStorage(string storage)
Parameters
storagestringName of storage property or field for current column.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsAlias(Expression<Func<TEntity, object>>)
Sets that property is alias to another member.
public PropertyMappingBuilder<TEntity, TProperty> IsAlias(Expression<Func<TEntity, object>> aliasMember)
Parameters
aliasMemberExpression<Func<TEntity, object>>Alias member getter expression.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsAlias(string)
Sets that property is alias to another member.
public PropertyMappingBuilder<TEntity, TProperty> IsAlias(string aliasMember)
Parameters
aliasMemberstringAlias member name.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsColumn()
Sets current member to be included into mapping as column.
public PropertyMappingBuilder<TEntity, TProperty> IsColumn()
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsDiscriminator(bool)
Marks current column as discriminator column for inheritance mapping.
public PropertyMappingBuilder<TEntity, TProperty> IsDiscriminator(bool isDiscriminator = true)
Parameters
isDiscriminatorboolIf
true- column is used as inheritance mapping discriminator.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsExpression<TR>(Expression<Func<TEntity, TR>>, bool, string?)
Configure property as alias to another member.
public PropertyMappingBuilder<TEntity, TProperty> IsExpression<TR>(Expression<Func<TEntity, TR>> expression, bool isColumn = false, string? alias = null)
Parameters
expressionExpression<Func<TEntity, TR>>Expression for mapping member during read.
isColumnboolIndicates whether a property value should be filled during entity materialization (calculated property).
aliasstringOptional alias for specific member expression. By default Member Name is used.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
Type Parameters
TR
IsIdentity()
Marks current column as identity column.
public PropertyMappingBuilder<TEntity, TProperty> IsIdentity()
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsNotColumn()
Sets current member to be excluded from mapping.
public PropertyMappingBuilder<TEntity, TProperty> IsNotColumn()
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current mapping builder.
IsNotNull()
Sets whether a column can contain NULL values.
public PropertyMappingBuilder<TEntity, TProperty> IsNotNull()
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsNullable(bool)
Sets whether a column can contain NULL values.
public PropertyMappingBuilder<TEntity, TProperty> IsNullable(bool isNullable = true)
Parameters
isNullableboolIf
true- column could containNULLvalues.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
IsPrimaryKey(int)
Marks current column as primary key member.
public PropertyMappingBuilder<TEntity, TProperty> IsPrimaryKey(int order = -1)
Parameters
orderintOrder of property in primary key.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
Member<TMember>(Expression<Func<TEntity, TMember>>)
Adds member mapping to current entity.
public PropertyMappingBuilder<TEntity, TMember> Member<TMember>(Expression<Func<TEntity, TMember>> func)
Parameters
funcExpression<Func<TEntity, TMember>>Column mapping property or field getter expression.
Returns
- PropertyMappingBuilder<TEntity, TMember>
Returns fluent property mapping builder.
Type Parameters
TMember
Property<TMember>(Expression<Func<TEntity, TMember>>)
Adds new column mapping to current column's entity.
public PropertyMappingBuilder<TEntity, TMember> Property<TMember>(Expression<Func<TEntity, TMember>> func)
Parameters
funcExpression<Func<TEntity, TMember>>Column mapping property or field getter expression.
Returns
- PropertyMappingBuilder<TEntity, TMember>
Returns property mapping builder.
Type Parameters
TMember
SkipOnEntityFetch(bool)
Marks current column to be skipped by default during a full entity fetch
public PropertyMappingBuilder<TEntity, TProperty> SkipOnEntityFetch(bool skipOnEntityFetch = true)
Parameters
skipOnEntityFetchboolIf
true, column won't be fetched unless explicity selected in a Linq query.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.
UseSequence(string, string?, string?)
Specifies value generation sequence for current column. See SequenceNameAttribute notes for list of supported databases.
public PropertyMappingBuilder<TEntity, TProperty> UseSequence(string sequenceName, string? schema = null, string? configuration = null)
Parameters
sequenceNamestringName of sequence.
schemastringOptional sequence schema name.
configurationstringOptional mapping configuration name. If not specified, entity configuration used.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns current column mapping builder.