Table of Contents

Class CosmosModelBuilder

Namespace
eQuantic.Core.Data.CosmosDb
Assembly
eQuantic.Core.Data.CosmosDb.dll

Fluent builder for the CosmosModel — one Entity call per mapped type.

public sealed class CosmosModelBuilder
Inheritance
CosmosModelBuilder
Inherited Members

Methods

Build()

Builds the model. The DI extensions call this for you; call it directly when hosting without DI — the built model feeds Create(string, CosmosModel, ILoggerFactory?) and Explain().

public CosmosModel Build()

Returns

CosmosModel

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

Declares a value conversion for every member of type TMember: documents store TStored, entities keep TMember. Deliberately type-level (unlike the relational per-member Converts): the SDK's LINQ translation serializes a filter's constants by their type, so only a type-level converter keeps x => x.Status == Status.Active comparing against the stored representation.

public CosmosModelBuilder Converts<TMember, TStored>(Func<TMember, TStored> toStored, Func<TStored, TMember> fromStored)

Parameters

toStored Func<TMember, TStored>

Converts the CLR value to its stored representation.

fromStored Func<TStored, TMember>

Converts the stored representation back.

Returns

CosmosModelBuilder

Type Parameters

TMember

The CLR type on the entity.

TStored

The stored (JSON) type.

Entity<TEntity>(Action<CosmosEntityBuilder<TEntity>>)

Maps TEntity to a container and partition key.

public CosmosModelBuilder Entity<TEntity>(Action<CosmosEntityBuilder<TEntity>> configure) where TEntity : class

Parameters

configure Action<CosmosEntityBuilder<TEntity>>

The fluent configuration.

Returns

CosmosModelBuilder

The same builder for chaining.

Type Parameters

TEntity

The entity type.