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
TEntityThe 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
selectorExpression<Func<TEntity, TMember>>The member selector.
descendingboolWhether the declared order is descending.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TMemberThe 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
navigationExpression<Func<TEntity, IEnumerable<TElement>>>The navigation selector.
foreignKeyExpression<Func<TElement, object>>The foreign-key member on the element, pointing back at this entity's key.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TElementThe 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
selectorExpression<Func<TEntity, TMember>>The member selector.
columnNamestringThe column name.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TMemberThe 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
selectorExpression<Func<TEntity, TMember>>The member selector.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TMemberThe 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
selectorExpression<Func<TEntity, TMember>>The member selector.
toStoredFunc<TMember, TStored>Converts the member value into the stored value.
fromStoredFunc<TStored, TMember>Converts the stored value back into the member value.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TMemberThe member type.
TStoredThe 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
selectorExpression<Func<TEntity, TMember>>The member selector.
lengthintThe maximum text length (0 = the dialect's default).
precisionintThe decimal precision (0 = the dialect's default).
scaleintThe decimal scale (with
precision).
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TMemberThe 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
selectorExpression<Func<TEntity, TMember>>The member selector.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TMemberThe 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
selectorExpression<Func<TEntity, TKey>>The member selector.
generatedboolWhether the database generates the key (identity): inserts omit it and read it back.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TKeyThe 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
navigationExpression<Func<TEntity, TTarget>>The navigation selector.
foreignKeyExpression<Func<TEntity, object>>The foreign-key member on this entity.
Returns
- RelationalEntityBuilder<TEntity>
Type Parameters
TTargetThe 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
selectorExpression<Func<TEntity, string>>The member selector.
modeSearchModeWhat 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
namestringThe table name.
Returns
- RelationalEntityBuilder<TEntity>