Soenneker.Cosmos.Repository
4.0.8156
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Cosmos.Repository --version 4.0.8156
NuGet\Install-Package Soenneker.Cosmos.Repository -Version 4.0.8156
<PackageReference Include="Soenneker.Cosmos.Repository" Version="4.0.8156" />
<PackageVersion Include="Soenneker.Cosmos.Repository" Version="4.0.8156" />
<PackageReference Include="Soenneker.Cosmos.Repository" />
paket add Soenneker.Cosmos.Repository --version 4.0.8156
#r "nuget: Soenneker.Cosmos.Repository, 4.0.8156"
#:package Soenneker.Cosmos.Repository@4.0.8156
#addin nuget:?package=Soenneker.Cosmos.Repository&version=4.0.8156
#tool nuget:?package=Soenneker.Cosmos.Repository&version=4.0.8156
Soenneker.Cosmos.Repository
Defines the core repository contract for a Cosmos DB document type.
Install
dotnet add package Soenneker.Cosmos.Repository
Quick start
using Soenneker.Cosmos.Repository.Abstract;
ICosmosRepository<TDocument> cosmosRepository = /* resolve from DI */;
var result = await cosmosRepository.AddItem(/* supply document */ default!, default);
Will throw exception if item id already exists.
What you get
ICosmosRepository<TDocument>— Defines the core repository contract for a Cosmos DB document type.ICosmosRepository— Provides non-generic access to Cosmos repository operations.ICosmosRepositoryContext— Defines the container level context.
API at a glance
| API | What it does | Result / important behavior |
|---|---|---|
ICosmosRepository<TDocument>.AddItem(document, useQueue, excludeResponse, cancellationToken) |
Will throw exception if item id already exists. | Fully qualified Id string (partitionKey:documentId). |
ICosmosRepository<TDocument>.AddItems(documents, delayMs, useQueue, excludeResponse, cancellationToken) |
Essentially just a helper that iterates over a list, calling AddItem. |
The fully qualified IDs of the documents added by the operation. |
ICosmosRepository<TDocument>.CreateAuditItem(eventType, entityId, item, cancellationToken) |
Look up the user (if it exists), create an Audit document, and add it to the audit container. Always uses the queue. | A task that completes when the audit item creation is complete. |
ICosmosRepository<TDocument>.CreateAuditItem(eventType, entityId, entityJson, cancellationToken) |
Look up the user (if it exists), create an Audit document, and add it to the audit container. Always uses the queue. | A task that completes when the audit item creation is complete. |
ICosmosRepository<TDocument>.DeleteItemIfMatch(item, cancellationToken) |
Deletes a wrapped item only when its ETag still matches. Cosmos DB throws a 412 Precondition Failed response when the item has changed. | Completes only when the ETag still matches; Cosmos DB rejects a stale document with HTTP 412 Precondition Failed. |
ICosmosRepository<TDocument>.DeleteItem(entityId, useQueue, cancellationToken) |
Hard deletes one item by Id (partition and document, or one guid if they're the same). Will not throw. | A task that completes when the item deletion is complete. |
ICosmosRepository<TDocument>.DeleteItemIfMatch(entityId, expectedETag, cancellationToken) |
Deletes an item only when its current ETag matches expectedETag. Cosmos DB throws a 412 Precondition Failed response when the item has changed. |
Completes only when the ETag still matches; Cosmos DB rejects a stale document with HTTP 412 Precondition Failed. |
ICosmosRepository<TDocument>.DeleteItemIfMatch(documentId, partitionKey, expectedETag, cancellationToken) |
Deletes an item only when its current ETag matches expectedETag. |
Applies the operation only to documents whose current ETag matches the supplied expected value. |
ICosmosRepository<TDocument>.DeleteAll(delayMs, useQueue, cancellationToken) |
Deletes all items. | A task representing the asynchronous operation. |
ICosmosRepository<TDocument>.DeleteIdsIfMatch(ids, expectedETags, delayMs, cancellationToken) |
Deletes every item only when its current ETag matches the value keyed by its full ID. | Applies the operation only to documents whose current ETag matches the supplied expected value. |
ICosmosRepository<TDocument>.DeleteIdsParallelIfMatch(ids, expectedETags, maxConcurrency, cancellationToken) |
Deletes every item in parallel only when its current ETag matches the value keyed by its full ID. | Applies the operation only to documents whose current ETag matches the supplied expected value. |
ICosmosRepository<TDocument>.Exists(id, cancellationToken) |
Checks whether the repository contains the fully qualified document ID. | Returns true when the document exists; otherwise, false. |
ICosmosRepository<TDocument>.Exists(documentId, partitionKey, cancellationToken) |
Checks whether the specified partition contains the document ID. | Returns true when the document exists; otherwise, false. |
ICosmosRepository<TDocument>.Exists(query, cancellationToken) |
Checks whether the query matches at least one document. | Returns true when a match exists; otherwise, false. |
ICosmosRepository<TDocument>.ExistsByPartitionKey(partitionKey, cancellationToken) |
Checks for by Partition Key. | Returns true when at least one matching document exists; otherwise, false. |
ICosmosRepository<TDocument>.GetItemWithETag(id, cancellationToken) |
Gets an item together with the ETag required for a subsequent conditional write. | Applies the operation only to documents whose current ETag matches the supplied expected value. |
ICosmosRepository<TDocument>.GetItemWithETag(documentId, partitionKey, cancellationToken) |
Gets an item together with the ETag required for a subsequent conditional write. | Applies the operation only to documents whose current ETag matches the supplied expected value. |
ICosmosRepository<TDocument>.GetItem(id, cancellationToken) |
Get one item by Id (partition id and document id, or one guid if they're the same) Will not throw. | null if cannot be found. |
Important behavior
ICosmosRepository<TDocument>.MutateItem(id, mutation, cancellationToken, maxAttempts): The mutation may be invoked more than once and must only describe the intended document delta. It must not perform non-idempotent external side effects.ICosmosRepository<TDocument>.ExecuteOnGetItemsPaged(query, resultTask, cancellationToken): Include anORDER BYclause when continuation-token paging must be stable.ICosmosRepository<TDocument>.GetItemsPaged(queryDefinition, pageSize, continuationToken, cancellationToken): Include anORDER BYclause; without deterministic ordering, continuation tokens may not resume reliably.ICosmosRepository<TDocument>.GetItemsPaged(query, cancellationToken): Include anORDER BYclause when consuming multiple pages.
Practical notes
- Cancellation stops pending work; it does not undo work that has already completed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.ConcurrentProcessing.Executor (>= 4.0.323)
- Soenneker.Constants.Data (>= 4.0.639)
- Soenneker.Cosmos.Container (>= 4.0.2496)
- Soenneker.Cosmos.RequestOptions (>= 4.0.174)
- Soenneker.Documents.Audit (>= 4.0.2570)
- Soenneker.Dtos.IdNamePair (>= 4.0.721)
- Soenneker.Dtos.IdPartitionPair (>= 4.0.723)
- Soenneker.Utils.BackgroundQueue (>= 4.0.2459)
- Soenneker.Utils.Json (>= 4.0.2648)
- Soenneker.Utils.Method (>= 4.0.459)
- Soenneker.Utils.PooledStringBuilders (>= 4.0.28)
- Soenneker.Utils.UserContext (>= 4.0.1773)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Soenneker.Cosmos.Repository:
| Package | Downloads |
|---|---|
|
Soenneker.Managers.Entities
An abstract generic manager class provides CRUD operations for entities mapped to Cosmos DB documents |
|
|
Soenneker.Cosmos.Repositories.Audits
A data persistence abstraction layer for Cosmos DB Audit type documents |
|
|
Soenneker.Cosmos.Repositories.Shared
A data persistence abstraction layer for Cosmos DB containers that have multiple document types |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.8171 | 0 | 8/30/2026 |
| 4.0.8166 | 0 | 8/30/2026 |
| 4.0.8163 | 0 | 8/30/2026 |
| 4.0.8161 | 0 | 8/30/2026 |
| 4.0.8160 | 0 | 8/30/2026 |
| 4.0.8156 | 0 | 8/29/2026 |
| 4.0.8151 | 22 | 8/29/2026 |
| 4.0.8150 | 29 | 8/29/2026 |
| 4.0.8149 | 28 | 8/29/2026 |
| 4.0.8145 | 123 | 8/27/2026 |
| 4.0.8144 | 132 | 8/26/2026 |
| 4.0.8143 | 99 | 8/26/2026 |
| 4.0.8142 | 94 | 8/26/2026 |
| 4.0.8141 | 111 | 8/26/2026 |
| 4.0.8140 | 116 | 8/25/2026 |
| 4.0.8139 | 71 | 8/25/2026 |
| 4.0.8136 | 180 | 8/22/2026 |
| 4.0.8135 | 155 | 8/22/2026 |
| 4.0.8134 | 131 | 8/22/2026 |
| 4.0.8133 | 129 | 8/22/2026 |
Update dependency Soenneker.ConcurrentProcessing.Executor to 4.0.323 (#9040)