Table of Contents

Class RelationalEntityBuilder<TEntity>

Namespace
eQuantic.Core.Data.Relational
Assembly
eQuantic.Core.Data.Relational.dll

Fluent configuration for one entity's relational mapping.

public sealed class RelationalEntityBuilder<TEntity> where TEntity : class

Type Parameters

TEntity

The entity type.

Inheritance
RelationalEntityBuilder<TEntity>
Inherited Members

Methods

ClusteringKey<TMember>(Expression<Func<TEntity, TMember>>, bool)

Declares an ordered-read member — "I read this sorted" — materialized as a multi-column index with the declared directions by the migration's EnsureCollection(). Call in order for several.

public RelationalEntityBuilder<TEntity> ClusteringKey<TMember>(Expression<Func<TEntity, TMember>> selector, bool descending = false)

Parameters

selector Expression<Func<TEntity, TMember>>

The member selector.

descending bool

Whether the declared order is descending.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TMember

The member type.

Collection<TElement>(Expression<Func<TEntity, IEnumerable<TElement>?>>, Expression<Func<TElement, object?>>)

Declares a collection navigation with an explicit foreign key — for schemas the {Entity}Id convention does not fit. Include loads it with one follow-up IN query.

public RelationalEntityBuilder<TEntity> Collection<TElement>(Expression<Func<TEntity, IEnumerable<TElement>?>> navigation, Expression<Func<TElement, object?>> foreignKey) where TElement : class

Parameters

navigation Expression<Func<TEntity, IEnumerable<TElement>>>

The navigation selector.

foreignKey Expression<Func<TElement, object>>

The foreign-key member on the element, pointing back at this entity's key.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TElement

The element entity type.

Column<TMember>(Expression<Func<TEntity, TMember>>, string)

Overrides the stored column name for a member (the dialect's naming convention applies otherwise).

public RelationalEntityBuilder<TEntity> Column<TMember>(Expression<Func<TEntity, TMember>> selector, string columnName)

Parameters

selector Expression<Func<TEntity, TMember>>

The member selector.

columnName string

The column name.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TMember

The member type.

ConcurrencyToken<TMember>(Expression<Func<TEntity, TMember>>)

Declares the optimistic-concurrency token (an int, long or Guid member): every update and delete of the entity matches the token it read (WHERE … AND version = @old) and bumps it; a commit whose writes miss rows throws ConcurrencyConflictException and rolls back — the lost update is caught, not silently overwritten.

public RelationalEntityBuilder<TEntity> ConcurrencyToken<TMember>(Expression<Func<TEntity, TMember>> selector)

Parameters

selector Expression<Func<TEntity, TMember>>

The member selector.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TMember

The member type.

Converts<TMember, TStored>(Expression<Func<TEntity, TMember>>, Func<TMember, TStored>, Func<TStored, TMember>)

Declares a value converter: the member (a Value Object, an enum-as-string — any domain type) stores as the scalar TStored. The conversion applies everywhere the member crosses the engine — DDL column type, inserts and updates (set-based included), filter values and materialization — so the domain type never leaks to the driver.

public RelationalEntityBuilder<TEntity> Converts<TMember, TStored>(Expression<Func<TEntity, TMember>> selector, Func<TMember, TStored> toStored, Func<TStored, TMember> fromStored)

Parameters

selector Expression<Func<TEntity, TMember>>

The member selector.

toStored Func<TMember, TStored>

Converts the member value into the stored value.

fromStored Func<TStored, TMember>

Converts the stored value back into the member value.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TMember

The member type.

TStored

The stored scalar type.

Facet<TMember>(Expression<Func<TEntity, TMember>>, int, int, int)

Declares storage facets for a member: a text length, a decimal precision/scale (the DDL sizes the column).

public RelationalEntityBuilder<TEntity> Facet<TMember>(Expression<Func<TEntity, TMember>> selector, int length = 0, int precision = 0, int scale = 0)

Parameters

selector Expression<Func<TEntity, TMember>>

The member selector.

length int

The maximum text length (0 = the dialect's default).

precision int

The decimal precision (0 = the dialect's default).

scale int

The decimal scale (with precision).

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TMember

The member type.

Ignore<TMember>(Expression<Func<TEntity, TMember>>)

Excludes a member from the mapping (navigations are excluded automatically; this is for the rest).

public RelationalEntityBuilder<TEntity> Ignore<TMember>(Expression<Func<TEntity, TMember>> selector)

Parameters

selector Expression<Func<TEntity, TMember>>

The member selector.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TMember

The member type.

Key<TKey>(Expression<Func<TEntity, TKey>>, bool)

Declares the key member (defaults to a member named Id) — or a composite key with an anonymous projection: Key(x => new { x.OrderId, x.LineNumber }), member order defining the column order. Point lookups take the same shape as a tuple (GetAsync((orderId, lineNumber))); a composite key cannot be database-generated.

public RelationalEntityBuilder<TEntity> Key<TKey>(Expression<Func<TEntity, TKey>> selector, bool generated = false)

Parameters

selector Expression<Func<TEntity, TKey>>

The member selector.

generated bool

Whether the database generates the key (identity): inserts omit it and read it back.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TKey

The member (or anonymous projection) type.

Reference<TTarget>(Expression<Func<TEntity, TTarget?>>, Expression<Func<TEntity, object?>>)

Declares a reference navigation with an explicit foreign key — for schemas the {Nav}Id convention does not fit. Include loads it with one follow-up IN query.

public RelationalEntityBuilder<TEntity> Reference<TTarget>(Expression<Func<TEntity, TTarget?>> navigation, Expression<Func<TEntity, object?>> foreignKey) where TTarget : class

Parameters

navigation Expression<Func<TEntity, TTarget>>

The navigation selector.

foreignKey Expression<Func<TEntity, object>>

The foreign-key member on this entity.

Returns

RelationalEntityBuilder<TEntity>

Type Parameters

TTarget

The referenced entity type.

SearchIndex(Expression<Func<TEntity, string?>>, SearchMode)

Declares a search-indexed text member. Relational LIKE already pushes down — this is about the index: on PostgreSQL the migration's EnsureCollection() materializes a GIN trigram index (pg_trgm) so Contains/EndsWith stop scanning; dialects without an equivalent ignore the declaration (same semantics, unindexed plan — Explain() says which).

public RelationalEntityBuilder<TEntity> SearchIndex(Expression<Func<TEntity, string?>> selector, SearchMode mode = SearchMode.Contains)

Parameters

selector Expression<Func<TEntity, string>>

The member selector.

mode SearchMode

What the search should serve (Contains by default).

Returns

RelationalEntityBuilder<TEntity>

Table(string)

Sets the table name (defaults to the entity type name through the dialect's naming convention).

public RelationalEntityBuilder<TEntity> Table(string name)

Parameters

name string

The table name.

Returns

RelationalEntityBuilder<TEntity>