Class EntityMappingBuilder<TEntity>
Fluent mapping entity builder.
public class EntityMappingBuilder<TEntity>
Type Parameters
TEntityEntity mapping type.
- Inheritance
-
EntityMappingBuilder<TEntity>
- Inherited Members
- Extension Methods
Constructors
EntityMappingBuilder(FluentMappingBuilder, string?)
Creates entity mapping builder.
public EntityMappingBuilder(FluentMappingBuilder builder, string? configuration)
Parameters
builderFluentMappingBuilderFluent mapping builder.
configurationstringOptional mapping schema configuration name, for which this entity builder should be taken into account. ProviderName for standard configuration names.
Properties
Configuration
Gets mapping schema configuration name, for which this entity builder should be taken into account. ProviderName for standard configuration names.
public string? Configuration { get; }
Property Value
Methods
Association<TOther>(Expression<Func<TEntity, IEnumerable<TOther>>>, Expression<Func<TEntity, IDataContext, IQueryable<TOther>>>, bool?)
Adds one-to-many association mapping to current 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 one-to-many association mapping to current 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 one-to-one association mapping to current 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 one-to-one association mapping to current 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 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<TProperty, TThisKey, TOtherKey>(Expression<Func<TEntity, TProperty>>, Expression<Func<TEntity, TThisKey>>, Expression<Func<TProperty, TOtherKey>>, bool?)
Adds association mapping to current entity.
public PropertyMappingBuilder<TEntity, TProperty> Association<TProperty, TThisKey, TOtherKey>(Expression<Func<TEntity, TProperty>> prop, Expression<Func<TEntity, TThisKey>> thisKey, Expression<Func<TProperty, TOtherKey>> otherKey, bool? canBeNull = null)
Parameters
propExpression<Func<TEntity, TProperty>>Association member getter expression.
thisKeyExpression<Func<TEntity, TThisKey>>This association key getter expression.
otherKeyExpression<Func<TProperty, TOtherKey>>Other association key getter expression.
canBeNullbool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns fluent property mapping builder.
Type Parameters
TPropertyAssociation 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
DynamicColumnsStore(Expression<Func<TEntity, object?>>)
Adds dynamic columns store dictionary member mapping to current entity.
public EntityMappingBuilder<TEntity> DynamicColumnsStore(Expression<Func<TEntity, object?>> func)
Parameters
funcExpression<Func<TEntity, object>>Column mapping property or field getter expression.
Returns
- EntityMappingBuilder<TEntity>
Returns fluent property mapping builder.
DynamicPropertyAccessors(Expression<Func<TEntity, string, object?, object?>>, Expression<Action<TEntity, string, object?>>)
Specify value set/get logic for dynamic properties, defined using Property<T>(object?, string) API.
public EntityMappingBuilder<TEntity> DynamicPropertyAccessors(Expression<Func<TEntity, string, object?, object?>> getter, Expression<Action<TEntity, string, object?>> setter)
Parameters
getterExpression<Func<TEntity, string, object, object>>Getter expression. Parameters:
- entity instance
- column name in database
- default value for column type (from MappingSchema)
setterExpression<Action<TEntity, string, object>>Setter expression. Parameters:
- entity instance
- column name in database
- column value to set
Returns
- EntityMappingBuilder<TEntity>
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 new fluent entity mapping builder.
Type Parameters
TEMapping type.
HasAttribute(MappingAttribute)
Adds mapping attribute to current entity.
public EntityMappingBuilder<TEntity> HasAttribute(MappingAttribute attribute)
Parameters
attributeMappingAttributeMapping attribute to add.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasAttribute(Expression<Func<TEntity, object?>>, MappingAttribute)
Adds mapping attribute to a member, specified using lambda expression.
public EntityMappingBuilder<TEntity> HasAttribute(Expression<Func<TEntity, object?>> func, MappingAttribute attribute)
Parameters
funcExpression<Func<TEntity, object>>Target member, specified using lambda expression.
attributeMappingAttributeMapping attribute to add to specified member.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasAttribute(LambdaExpression, MappingAttribute)
Adds mapping attribute to a member, specified using lambda expression.
public EntityMappingBuilder<TEntity> HasAttribute(LambdaExpression func, MappingAttribute attribute)
Parameters
funcLambdaExpressionTarget member, specified using lambda expression.
attributeMappingAttributeMapping attribute to add to specified member.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasAttribute(MemberInfo, MappingAttribute)
Adds mapping attribute to specified member.
public EntityMappingBuilder<TEntity> HasAttribute(MemberInfo memberInfo, MappingAttribute attribute)
Parameters
memberInfoMemberInfoTarget member.
attributeMappingAttributeMapping attribute to add to specified member.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasColumn(Expression<Func<TEntity, object?>>, int)
Adds column mapping to current entity.
public EntityMappingBuilder<TEntity> HasColumn(Expression<Func<TEntity, object?>> func, int order = -1)
Parameters
funcExpression<Func<TEntity, object>>Column member getter expression.
orderintUnused.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasDatabaseName(string)
Sets database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
public EntityMappingBuilder<TEntity> HasDatabaseName(string databaseName)
Parameters
databaseNamestringDatabase name.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasIdentity<TProperty>(Expression<Func<TEntity, TProperty>>)
Adds identity column mapping to current entity.
public EntityMappingBuilder<TEntity> HasIdentity<TProperty>(Expression<Func<TEntity, TProperty>> func)
Parameters
funcExpression<Func<TEntity, TProperty>>Identity field getter expression.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Type Parameters
TProperty
HasIsTemporary(bool)
Sets linked server name. See IsTemporary<T>(ITable<T>, bool) method for support information per provider.
public EntityMappingBuilder<TEntity> HasIsTemporary(bool isTemporary = true)
Parameters
isTemporaryboolLinked server name.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasPrimaryKey<TProperty>(Expression<Func<TEntity, TProperty>>, int)
Adds primary key mapping to current entity.
public EntityMappingBuilder<TEntity> HasPrimaryKey<TProperty>(Expression<Func<TEntity, TProperty>> func, int order = -1)
Parameters
funcExpression<Func<TEntity, TProperty>>Primary key getter expression.
orderintPrimary key field order. When multiple fields specified by getter expression, fields will be ordered from first mentioned field to last one starting from provided order with step
1.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Type Parameters
TProperty
HasQueryFilter(Func<IQueryable<TEntity>, IDataContext, IQueryable<TEntity>>)
Specifies a LINQ IQueryable<T> function that will automatically be applied to any queries targeting this entity type.
public EntityMappingBuilder<TEntity> HasQueryFilter(Func<IQueryable<TEntity>, IDataContext, IQueryable<TEntity>> filterFunc)
Parameters
filterFuncFunc<IQueryable<TEntity>, IDataContext, IQueryable<TEntity>>The LINQ predicate expression.
Returns
- EntityMappingBuilder<TEntity>
The same builder instance so that multiple configuration calls can be chained.
HasQueryFilter(Expression<Func<TEntity, IDataContext, bool>>)
Specifies a LINQ predicate expression that will automatically be applied to any queries targeting this entity type.
public EntityMappingBuilder<TEntity> HasQueryFilter(Expression<Func<TEntity, IDataContext, bool>> filter)
Parameters
filterExpression<Func<TEntity, IDataContext, bool>>The LINQ predicate expression.
Returns
- EntityMappingBuilder<TEntity>
The same builder instance so that multiple configuration calls can be chained.
HasQueryFilter<TDataContext>(Func<IQueryable<TEntity>, TDataContext, IQueryable<TEntity>>)
Specifies a LINQ IQueryable<T> function that will automatically be applied to any queries targeting this entity type.
public EntityMappingBuilder<TEntity> HasQueryFilter<TDataContext>(Func<IQueryable<TEntity>, TDataContext, IQueryable<TEntity>> filterFunc) where TDataContext : IDataContext
Parameters
filterFuncFunc<IQueryable<TEntity>, TDataContext, IQueryable<TEntity>>The LINQ predicate expression.
Returns
- EntityMappingBuilder<TEntity>
The same builder instance so that multiple configuration calls can be chained.
Type Parameters
TDataContext
HasQueryFilter<TDataContext>(Expression<Func<TEntity, TDataContext, bool>>)
Specifies a LINQ predicate expression that will automatically be applied to any queries targeting this entity type.
public EntityMappingBuilder<TEntity> HasQueryFilter<TDataContext>(Expression<Func<TEntity, TDataContext, bool>> filter) where TDataContext : IDataContext
Parameters
filterExpression<Func<TEntity, TDataContext, bool>>The LINQ predicate expression.
Returns
- EntityMappingBuilder<TEntity>
The same builder instance so that multiple configuration calls can be chained.
Type Parameters
TDataContext
HasSchemaName(string)
Sets database schema/owner name for current entity, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
public EntityMappingBuilder<TEntity> HasSchemaName(string schemaName)
Parameters
schemaNamestringSchema/owner name.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasServerName(string)
Sets linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
public EntityMappingBuilder<TEntity> HasServerName(string serverName)
Parameters
serverNamestringLinked server name.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasSkipValuesOnInsert(Expression<Func<TEntity, object?>>, params object?[])
Adds option for skipping values for column on current entity during insert.
public EntityMappingBuilder<TEntity> HasSkipValuesOnInsert(Expression<Func<TEntity, object?>> func, params object?[] values)
Parameters
funcExpression<Func<TEntity, object>>Column member getter expression.
valuesobject[]Values that should be skipped during insert.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasSkipValuesOnUpdate(Expression<Func<TEntity, object?>>, params object?[])
Adds option for skipping values for column on current entity during update.
public EntityMappingBuilder<TEntity> HasSkipValuesOnUpdate(Expression<Func<TEntity, object?>> func, params object?[] values)
Parameters
funcExpression<Func<TEntity, object>>Column member getter expression.
valuesobject[]Values that should be skipped during update.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasTableName(string)
Sets database table name for current entity.
public EntityMappingBuilder<TEntity> HasTableName(string tableName)
Parameters
tableNamestringTable name.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
HasTableOptions(TableOptions)
Sets Table options. See TableOptions<T>(ITable<T>, TableOptions) method for support information per provider.
public EntityMappingBuilder<TEntity> HasTableOptions(TableOptions tableOptions)
Parameters
tableOptionsTableOptionsTable options.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Ignore(Expression<Func<TEntity, object?>>, int)
Instruct LINQ to DB to not incude specified member into mapping.
public EntityMappingBuilder<TEntity> Ignore(Expression<Func<TEntity, object?>> func, int order = -1)
Parameters
funcExpression<Func<TEntity, object>>Member getter expression.
orderintUnused.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Inheritance<TS>(Expression<Func<TEntity, TS>>, TS, Type, bool)
Adds inheritance mapping for specified discriminator value.
public EntityMappingBuilder<TEntity> Inheritance<TS>(Expression<Func<TEntity, TS>> key, TS value, Type type, bool isDefault = false)
Parameters
keyExpression<Func<TEntity, TS>>Discriminator member getter expression.
valueTSDiscriminator value.
typeTypeMapping type, used with specified discriminator value.
isDefaultboolIf
true, current mapping type used by default.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Type Parameters
TSDiscriminator value type.
IsColumnNotRequired()
Sets if it is not required to use IsColumn() - all public fields and properties are treated as columns This is the default behaviour
public EntityMappingBuilder<TEntity> IsColumnNotRequired()
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
IsColumnRequired()
Sets if it is required to use IsColumn() to treat property or field as column
public EntityMappingBuilder<TEntity> IsColumnRequired()
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Member<TProperty>(Expression<Func<TEntity, TProperty>>)
Adds member mapping to current entity.
public PropertyMappingBuilder<TEntity, TProperty> Member<TProperty>(Expression<Func<TEntity, TProperty>> func)
Parameters
funcExpression<Func<TEntity, TProperty>>Column mapping property or field getter expression.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns fluent property mapping builder.
Type Parameters
TProperty
Property<TProperty>(Expression<Func<TEntity, TProperty>>)
Adds column mapping to current entity.
public PropertyMappingBuilder<TEntity, TProperty> Property<TProperty>(Expression<Func<TEntity, TProperty>> func)
Parameters
funcExpression<Func<TEntity, TProperty>>Column mapping property or field getter expression.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns fluent property mapping builder.
Type Parameters
TProperty