IEvangelist.Azure.CosmosRepository
2.1.1
See the version list below for details.
dotnet add package IEvangelist.Azure.CosmosRepository --version 2.1.1
NuGet\Install-Package IEvangelist.Azure.CosmosRepository -Version 2.1.1
<PackageReference Include="IEvangelist.Azure.CosmosRepository" Version="2.1.1" />
paket add IEvangelist.Azure.CosmosRepository --version 2.1.1
#r "nuget: IEvangelist.Azure.CosmosRepository, 2.1.1"
// Install IEvangelist.Azure.CosmosRepository as a Cake Addin #addin nuget:?package=IEvangelist.Azure.CosmosRepository&version=2.1.1 // Install IEvangelist.Azure.CosmosRepository as a Cake Tool #tool nuget:?package=IEvangelist.Azure.CosmosRepository&version=2.1.1
Azure Cosmos DB Repository .NET SDK
This package wraps the NuGet: Microsoft.Azure.Cosmos package,
exposing a simple dependency-injection enabled IRepository<T>
interface.
The repository is responsible for all
of the create, read, update, and delete (CRUD) operations on objects where T : Item
. The Item
type adds
several properties, one which is a globally unique identifier defined as:
[JsonProperty("id")]
public string Id { get; set; } = Guid.NewGuid().ToString();
Additionally, a type property exists which indicates the subclass name (this is used for filtering implicitly on your behalf):
[JsonProperty("type")]
public string Type { get; set; }
Finally, a partition key property is used internally to manage partitioning on your behalf. This can optionally be overridden on an item per item basis.
📣 Azure Cosmos DB - Official Blog
Getting started
Create an Azure Cosmos DB SQL resource.
Obtain the resource connection string from the Keys blade, be sure to get a connection string and not the key - these are different. The connection string is a compound key and endpoint URL.
Call
AddCosmosRepository
:public void ConfigureServices(IServiceCollection services) { services.AddCosmosRepository(); }
The optional
setupAction
allows consumers to manually configure theRepositoryOptions
object:public void ConfigureServices(IServiceCollection services) { services.AddCosmosRepository( options => { options.CosmosConnectionString = "< connection string >"; options.ContainerId = "data-store"; options.DatabaseId = "samples"; }); }
Define your object graph, objects must inherit
Item
, for example:using Microsoft.Azure.CosmosRepository; public class Person : Item { public string FirstName { get; set; } public string LastName { get; set; } }
Ask for an instance of
IRepository<TItem>
, in this case theTItem
isPerson
:using Microsoft.Azure.CosmosRepository; public class Consumer { readonly IRepository<Person> _repository; public Consumer(IRepository<Person> repository) => _repository = repository; // Use the repo... }
Perform any of the operations on the
_repository
instance, createPerson
records, update them, read them, or delete.Enjoy!
Configuration
When OptimizeBandwidth
is true
(its default value), the repository SDK reduces networking and
CPU load by not sending the resource back over the network and serializing it to the client. This is specific to writes,
such as create, update, and delete. For more information, see Optimizing bandwidth in the Azure Cosmos DB .NET SDK.
There is much debate with how to structure your database and corresponding containers. Many developers with relational
database design experience might prefer to have a single container per item type, while others understand that Azure Cosmos DB
will handle things correctly regardless. By default, the ContainerPerItemType
option is false
and
all items are persisted into the same container. However, when it is true
, each distinct subclass of
Item
gets its own container named by the class itself.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Azure.Cosmos (>= 3.14.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Logging (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on IEvangelist.Azure.CosmosRepository:
Package | Downloads |
---|---|
IEvangelist.Azure.CosmosRepository.AspNetCore
This client library enables client applications to connect to Azure Cosmos via a repository pattern around the official Azure Cosmos .NET SDK. Azure Cosmos is a globally distributed, multi-model database service. For more information, refer to http://azure.microsoft.com/services/cosmos-db/. |
|
IEvangelist.Azure.CosmosEventSourcing
This client library enables client applications to connect to Azure Cosmos and use it as an event sourcing store. |
|
AIC.Core.Data.CosmosDb
Package Description |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on IEvangelist.Azure.CosmosRepository:
Repository | Stars |
---|---|
IEvangelist/azure-cosmos-dotnet-repository
Wraps the .NET SDK for Azure Cosmos DB abstracting away the complexity, exposing a simple CRUD-based repository pattern
|
|
IEvangelist/learning-blazor
The application for the "Learning Blazor: Build Single Page Apps with WebAssembly and C#" O'Reilly Media book by David Pine.
|
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 202 | 11/21/2024 |
8.1.7 | 29,988 | 7/1/2024 |
8.1.6 | 549 | 6/30/2024 |
8.1.5 | 34,052 | 4/10/2024 |
8.1.4 | 28,676 | 3/7/2024 |
8.1.3 | 10,907 | 2/8/2024 |
8.1.2 | 72,936 | 11/29/2023 |
8.1.1 | 2,109 | 11/27/2023 |
8.1.0 | 1,084 | 11/27/2023 |
8.0.0 | 1,881 | 11/20/2023 |
7.1.0 | 16,908 | 9/30/2023 |
7.0.2 | 6,135 | 8/25/2023 |
7.0.1 | 47,890 | 1/22/2023 |
7.0.0 | 6,351 | 1/4/2023 |
3.7.0 | 104,097 | 8/14/2022 |
3.6.0 | 21,411 | 7/23/2022 |
3.5.5 | 13,964 | 6/9/2022 |
3.5.4 | 9,811 | 5/18/2022 |
3.5.3 | 28,372 | 4/7/2022 |
3.5.2 | 6,368 | 3/24/2022 |
3.5.1 | 5,680 | 3/17/2022 |
3.5.0 | 3,672 | 3/14/2022 |
3.4.1 | 1,741 | 3/11/2022 |
3.4.0 | 1,685 | 3/11/2022 |
3.3.0 | 1,833 | 3/10/2022 |
3.2.0 | 1,864 | 3/9/2022 |
3.1.0 | 1,847 | 3/7/2022 |
3.0.3 | 3,188 | 3/5/2022 |
3.0.2 | 2,316 | 3/5/2022 |
3.0.0 | 8,177 | 3/2/2022 |
2.12.1 | 43,377 | 2/2/2022 |
2.12.0 | 3,775 | 2/1/2022 |
2.12.0-pre1 | 922 | 1/21/2022 |
2.11.0 | 5,982 | 1/5/2022 |
2.10.1 | 1,826 | 1/4/2022 |
2.10.0 | 856 | 12/27/2021 |
2.9.0 | 801 | 12/22/2021 |
2.8.0 | 3,472 | 12/15/2021 |
2.7.1 | 950 | 12/15/2021 |
2.7.0 | 3,851 | 11/15/2021 |
2.6.0 | 3,431 | 11/3/2021 |
2.5.3 | 4,711 | 11/1/2021 |
2.5.2 | 1,600 | 10/22/2021 |
2.5.1 | 1,001 | 10/18/2021 |
2.5.0 | 3,642 | 9/23/2021 |
2.3.0 | 1,870 | 8/18/2021 |
2.2.0 | 1,599 | 7/20/2021 |
2.1.9 | 3,224 | 6/11/2021 |
2.1.6 | 2,115 | 5/10/2021 |
2.1.5 | 3,399 | 2/11/2021 |
2.1.4 | 6,805 | 2/1/2021 |
2.1.3 | 45,056 | 12/11/2020 |
2.1.2 | 1,019 | 12/2/2020 |
2.1.1 | 1,549 | 11/19/2020 |
2.1.0 | 1,854 | 11/10/2020 |
2.0.3 | 1,104 | 10/23/2020 |
2.0.2 | 1,252 | 10/12/2020 |
2.0.1 | 976 | 10/12/2020 |
2.0.0 | 1,001 | 10/9/2020 |
1.0.5 | 1,067 | 10/8/2020 |
1.0.4 | 1,214 | 10/7/2020 |
1.0.1 | 1,048 | 10/2/2020 |
1.0.0 | 1,101 | 10/1/2020 |
0.0.2-preview | 879 | 9/30/2020 |
0.0.1-preview | 910 | 9/17/2020 |