Soenneker.Cosmos.Repository 4.0.8156

Prefix Reserved
There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Cosmos.Repository" Version="4.0.8156" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Cosmos.Repository" Version="4.0.8156" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Cosmos.Repository" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Cosmos.Repository --version 4.0.8156
                    
#r "nuget: Soenneker.Cosmos.Repository, 4.0.8156"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Cosmos.Repository@4.0.8156
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Cosmos.Repository&version=4.0.8156
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Repository&version=4.0.8156
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 an ORDER BY clause when continuation-token paging must be stable.
  • ICosmosRepository<TDocument>.GetItemsPaged(queryDefinition, pageSize, continuationToken, cancellationToken): Include an ORDER BY clause; without deterministic ordering, continuation tokens may not resume reliably.
  • ICosmosRepository<TDocument>.GetItemsPaged(query, cancellationToken): Include an ORDER BY clause when consuming multiple pages.

Practical notes

  • Cancellation stops pending work; it does not undo work that has already completed.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

Update dependency Soenneker.ConcurrentProcessing.Executor to 4.0.323 (#9040)