Class CosmosModelBuilder
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
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
toStoredFunc<TMember, TStored>Converts the CLR value to its stored representation.
fromStoredFunc<TStored, TMember>Converts the stored representation back.
Returns
Type Parameters
TMemberThe CLR type on the entity.
TStoredThe 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
configureAction<CosmosEntityBuilder<TEntity>>The fluent configuration.
Returns
- CosmosModelBuilder
The same builder for chaining.
Type Parameters
TEntityThe entity type.