Table of Contents

Class CosmosEntityConfiguration

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

The Cosmos mapping for a single entity: which container it lives in, its partition key (path plus a selector to read the value from an instance for point writes), and container options such as TTL. Unlike MongoDB, Cosmos needs the partition key on every point read/write, so it must be declared up front.

public abstract class CosmosEntityConfiguration
Inheritance
CosmosEntityConfiguration
Derived
Inherited Members

Constructors

CosmosEntityConfiguration(Type, string, IReadOnlyList<string>)

Initializes the configuration with a (possibly hierarchical) partition key.

protected CosmosEntityConfiguration(Type entityType, string containerName, IReadOnlyList<string> partitionKeyPaths)

Parameters

entityType Type
containerName string
partitionKeyPaths IReadOnlyList<string>

CosmosEntityConfiguration(Type, string, string)

Initializes the configuration.

protected CosmosEntityConfiguration(Type entityType, string containerName, string partitionKeyPath)

Parameters

entityType Type
containerName string
partitionKeyPath string

Properties

ClusteringPaths

The ordered-read paths — materialized as a composite index on the container's policy (two or more).

public IReadOnlyList<(string Path, bool Descending)> ClusteringPaths { get; protected init; }

Property Value

IReadOnlyList<(string Path, bool Descending)>

ContainerName

The container name.

public string ContainerName { get; }

Property Value

string

DefaultTimeToLiveSeconds

The container's default time-to-live in seconds, or null for none.

public int? DefaultTimeToLiveSeconds { get; protected init; }

Property Value

int?

EntityType

The entity type.

public Type EntityType { get; }

Property Value

Type

HasConcurrencyToken

Whether the mapping declares a concurrency token (the document's _etag).

public bool HasConcurrencyToken { get; protected init; }

Property Value

bool

HasHierarchicalPartitionKey

Whether the partition key is hierarchical (more than one path).

public bool HasHierarchicalPartitionKey { get; }

Property Value

bool

IdDescription

Where the document id comes from (for Explain()).

public string IdDescription { get; protected init; }

Property Value

string

PartitionKeyPath

The partition key path (e.g. /countryCode). Throws for a hierarchical key — read PartitionKeyPaths there; nothing single-path can be silently right for it.

public string PartitionKeyPath { get; }

Property Value

string

PartitionKeyPaths

The partition key paths — one for a flat key, up to three for a hierarchical (multi-hash) key.

public IReadOnlyList<string> PartitionKeyPaths { get; protected init; }

Property Value

IReadOnlyList<string>

Methods

GetETag(object)

Reads the concurrency token (the document's _etag) from an entity instance, or null when the entity declares none / carries none. When present, a Modify/Merge stages a conditional replace (If-Match) instead of an unconditional upsert.

public virtual string? GetETag(object entity)

Parameters

entity object

The entity.

Returns

string

GetId(object)

Reads the Cosmos document id (always a string) from an entity instance.

public abstract string GetId(object entity)

Parameters

entity object

The entity.

Returns

string

GetPartitionKey(object)

Reads the partition key value from an entity instance (for point writes, patches and deletes).

public abstract PartitionKey GetPartitionKey(object entity)

Parameters

entity object

The entity.

Returns

PartitionKey