Class EntityMappingBuilder<TEntity>
Fluent mapping entity builder.
public class EntityMappingBuilder<TEntity>
Type Parameters
TEntity
Entity mapping type.
- Inheritance
-
EntityMappingBuilder<TEntity>
- Extension Methods
Constructors
EntityMappingBuilder(FluentMappingBuilder, string?)
Creates entity mapping builder.
public EntityMappingBuilder(FluentMappingBuilder builder, string? configuration)
Parameters
builder
FluentMappingBuilderFluent mapping builder.
configuration
stringOptional 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
prop
Expression<Func<TEntity, IEnumerable<TOther>>>Association member getter expression.
queryExpression
Expression<Func<TEntity, IDataContext, IQueryable<TOther>>>Query expression.
canBeNull
bool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, IEnumerable<TOther>>
Returns fluent property mapping builder.
Type Parameters
TOther
Other 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
prop
Expression<Func<TEntity, IEnumerable<TOther>>>Association member getter expression.
predicate
Expression<Func<TEntity, TOther, bool>>Predicate expression.
canBeNull
bool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, IEnumerable<TOther>>
Returns fluent property mapping builder.
Type Parameters
TOther
Other 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
prop
Expression<Func<TEntity, TOther>>Association member getter expression.
queryExpression
Expression<Func<TEntity, IDataContext, IQueryable<TOther>>>Query expression.
canBeNull
bool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TOther>
Returns fluent property mapping builder.
Type Parameters
TOther
Other 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
prop
Expression<Func<TEntity, TOther>>Association member getter expression.
predicate
Expression<Func<TEntity, TOther, bool>>Predicate expression
canBeNull
bool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TOther>
Returns fluent property mapping builder.
Type Parameters
TOther
Other 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
prop
Expression<Func<TEntity, IEnumerable<TPropElement>>>Association member getter expression.
thisKey
Expression<Func<TEntity, TThisKey>>This association key getter expression.
otherKey
Expression<Func<TPropElement, TOtherKey>>Other association key getter expression.
canBeNull
bool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, IEnumerable<TPropElement>>
Returns fluent property mapping builder.
Type Parameters
TPropElement
Association member type.
TThisKey
This association side key type.
TOtherKey
Other 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
prop
Expression<Func<TEntity, TProperty>>Association member getter expression.
thisKey
Expression<Func<TEntity, TThisKey>>This association key getter expression.
otherKey
Expression<Func<TProperty, TOtherKey>>Other association key getter expression.
canBeNull
bool?Defines type of join. True - left join, False - inner join.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns fluent property mapping builder.
Type Parameters
TProperty
Association member type.
TThisKey
This association side key type.
TOtherKey
Other 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
func
Expression<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
getter
Expression<Func<TEntity, string, object, object>>Getter expression. Parameters:
- entity instance
- column name in database
- default value for column type (from MappingSchema)
setter
Expression<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
configuration
stringOptional 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
TE
Mapping type.
HasAttribute(MappingAttribute)
Adds mapping attribute to current entity.
public EntityMappingBuilder<TEntity> HasAttribute(MappingAttribute attribute)
Parameters
attribute
MappingAttributeMapping 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
func
Expression<Func<TEntity, object>>Target member, specified using lambda expression.
attribute
MappingAttributeMapping 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
func
LambdaExpressionTarget member, specified using lambda expression.
attribute
MappingAttributeMapping 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
memberInfo
MemberInfoTarget member.
attribute
MappingAttributeMapping 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
func
Expression<Func<TEntity, object>>Column member getter expression.
order
intUnused.
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
databaseName
stringDatabase 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
func
Expression<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
isTemporary
boolLinked 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
func
Expression<Func<TEntity, TProperty>>Primary key getter expression.
order
intPrimary 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
filterFunc
Func<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
filter
Expression<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
filterFunc
Func<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
filter
Expression<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
schemaName
stringSchema/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
serverName
stringLinked 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
func
Expression<Func<TEntity, object>>Column member getter expression.
values
object[]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
func
Expression<Func<TEntity, object>>Column member getter expression.
values
object[]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
tableName
stringTable 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
tableOptions
TableOptionsTable 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
func
Expression<Func<TEntity, object>>Member getter expression.
order
intUnused.
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
key
Expression<Func<TEntity, TS>>Discriminator member getter expression.
value
TSDiscriminator value.
type
TypeMapping type, used with specified discriminator value.
isDefault
boolIf
true
, current mapping type used by default.
Returns
- EntityMappingBuilder<TEntity>
Returns current fluent entity mapping builder.
Type Parameters
TS
Discriminator 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
func
Expression<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
func
Expression<Func<TEntity, TProperty>>Column mapping property or field getter expression.
Returns
- PropertyMappingBuilder<TEntity, TProperty>
Returns fluent property mapping builder.
Type Parameters
TProperty