Class CosmosEntityConfiguration
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
entityTypeTypecontainerNamestringpartitionKeyPathsIReadOnlyList<string>
CosmosEntityConfiguration(Type, string, string)
Initializes the configuration.
protected CosmosEntityConfiguration(Type entityType, string containerName, string partitionKeyPath)
Parameters
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
ContainerName
The container name.
public string ContainerName { get; }
Property Value
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
HasConcurrencyToken
Whether the mapping declares a concurrency token (the document's _etag).
public bool HasConcurrencyToken { get; protected init; }
Property Value
HasHierarchicalPartitionKey
Whether the partition key is hierarchical (more than one path).
public bool HasHierarchicalPartitionKey { get; }
Property Value
IdDescription
Where the document id comes from (for Explain()).
public string IdDescription { get; protected init; }
Property Value
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
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
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
entityobjectThe entity.
Returns
GetId(object)
Reads the Cosmos document id (always a string) from an entity instance.
public abstract string GetId(object entity)
Parameters
entityobjectThe entity.
Returns
GetPartitionKey(object)
Reads the partition key value from an entity instance (for point writes, patches and deletes).
public abstract PartitionKey GetPartitionKey(object entity)
Parameters
entityobjectThe entity.