Encamina.Enmarcha.Data.Cosmos 8.1.6

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Encamina.Enmarcha.Data.Cosmos --version 8.1.6
NuGet\Install-Package Encamina.Enmarcha.Data.Cosmos -Version 8.1.6
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="Encamina.Enmarcha.Data.Cosmos" Version="8.1.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Encamina.Enmarcha.Data.Cosmos --version 8.1.6
#r "nuget: Encamina.Enmarcha.Data.Cosmos, 8.1.6"
#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.
// Install Encamina.Enmarcha.Data.Cosmos as a Cake Addin
#addin nuget:?package=Encamina.Enmarcha.Data.Cosmos&version=8.1.6

// Install Encamina.Enmarcha.Data.Cosmos as a Cake Tool
#tool nuget:?package=Encamina.Enmarcha.Data.Cosmos&version=8.1.6

Data - Cosmos

Nuget package

Cosmos Data project primarily contains Cosmos DB implementations based on the abstractions provided by Encamina.Enmarcha.Data.Abstractions, as well as some other utilities related to Cosmos DB.

Setup

Nuget package

First, install NuGet. Then, install Encamina.Enmarcha.Data.Cosmos from the package manager console:

PM> Install-Package Encamina.Enmarcha.Data.Cosmos

.NET CLI:

First, install .NET CLI. Then, install Encamina.Enmarcha.Data.Cosmos from the .NET CLI:

dotnet add package Encamina.Enmarcha.Data.Cosmos

How to use

In the following example, we will demonstrate how to configure and add an Cosmos DB implementation of the IAsyncRepository interface to the ServiceCollection, based on the CosmosRepository.

public class Foo 
{
    [JsonProperty("id")]
    public string Id { get; set; }

    [JsonProperty("text")]
    public string Text { get; set; }
}

First, you need to add the CosmosOptions to your project configuration. You can achieve this by using any configuration provider. The followng code is an example of how the settings would appear using the appsettings.json file:

  {
    // ...
    "CosmosOptions": {
        "AuthKey": "<Your-AuthKey>", // Authentication key required to connect with Azure Cosmos DB
        "Database": "<Your-Database>", // Database name to connect with Azure Cosmos DB
        "Endpoint": "<Your-Endpoint>", // Azure Cosmos DB service endpoint to use
        // ...
    },
    "CosmosDBContainerName": "<Your-Cosmos-DB-Container-Name>",
    // ...
  }

Next, in Program.cs or a similar entry point file in your project, add the following code:

// Entry point
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
   // ...
});

// ...

// Or others configuration providers...
builder.Configuration.AddJsonFile(@"appsettings.json", optional: true, reloadOnChange: true);  

builder.Services.AddCosmos(builder.Configuration);
builder.Services.AddScoped<IAsyncRepository<Foo>>(sp => sp.GetRequiredService<ICosmosRepositoryFactory>()
    .Create<Foo>(builder.Configuration.GetValue<string>("CosmosDBContainerName")));

And now, you can resolve the IAsyncRepository<Foo> interface with construction injection:

public class MyClass
{
    private readonly IAsyncRepository<Foo> fooRepository;

    public MyClass(IAsyncRepository<Foo> fooRepository)
    {
        this.fooRepository = fooRepository;
    }

    public async Task TestAddFooAsync(CancellationToken cts)
    {
        await fooRepository.AddAsync(new Foo() { Text = "Foo1", Id = Guid.NewGuid().ToString()}, cts);        
    }
}

Within the NuGet package, you will find some extension methods related to Cosmos DB in FeedIteratorExtensions.

Product 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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Encamina.Enmarcha.Data.Cosmos:

Package Downloads
Encamina.Enmarcha.SemanticKernel.Plugins.Chat

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.1.7-preview-09 0 7/3/2024
8.1.7-preview-08 21 7/2/2024
8.1.7-preview-07 68 6/10/2024
8.1.7-preview-06 64 6/10/2024
8.1.7-preview-05 80 6/6/2024
8.1.7-preview-04 70 6/6/2024
8.1.7-preview-03 77 5/24/2024
8.1.7-preview-02 61 5/10/2024
8.1.7-preview-01 66 5/8/2024
8.1.6 335 5/7/2024
8.1.6-preview-08 48 5/2/2024
8.1.6-preview-07 76 4/29/2024
8.1.6-preview-06 162 4/26/2024
8.1.6-preview-05 79 4/24/2024
8.1.6-preview-04 102 4/22/2024
8.1.6-preview-03 78 4/22/2024
8.1.6-preview-02 113 4/17/2024
8.1.6-preview-01 192 4/15/2024
8.1.5 113 4/15/2024
8.1.5-preview-15 85 4/10/2024
8.1.5-preview-14 110 3/20/2024
8.1.5-preview-13 68 3/18/2024
8.1.5-preview-12 96 3/13/2024
8.1.5-preview-11 75 3/13/2024
8.1.5-preview-10 104 3/13/2024
8.1.5-preview-09 71 3/12/2024
8.1.5-preview-08 59 3/12/2024
8.1.5-preview-07 91 3/8/2024
8.1.5-preview-06 191 3/8/2024
8.1.5-preview-05 78 3/7/2024
8.1.5-preview-04 91 3/7/2024
8.1.5-preview-03 95 3/7/2024
8.1.5-preview-02 131 2/28/2024
8.1.5-preview-01 109 2/19/2024
8.1.4 138 2/15/2024
8.1.3 115 2/13/2024
8.1.3-preview-07 68 2/13/2024
8.1.3-preview-06 79 2/12/2024
8.1.3-preview-05 71 2/9/2024
8.1.3-preview-04 70 2/8/2024
8.1.3-preview-03 64 2/7/2024
8.1.3-preview-02 70 2/2/2024
8.1.3-preview-01 58 2/2/2024
8.1.2 87 2/1/2024
8.1.2-preview-9 84 1/22/2024
8.1.2-preview-8 64 1/19/2024
8.1.2-preview-7 75 1/19/2024
8.1.2-preview-6 57 1/19/2024
8.1.2-preview-5 63 1/19/2024
8.1.2-preview-4 65 1/19/2024
8.1.2-preview-3 65 1/18/2024
8.1.2-preview-2 71 1/18/2024
8.1.2-preview-16 60 1/31/2024
8.1.2-preview-15 71 1/31/2024
8.1.2-preview-14 156 1/25/2024
8.1.2-preview-13 70 1/25/2024
8.1.2-preview-12 73 1/23/2024
8.1.2-preview-11 66 1/23/2024
8.1.2-preview-10 67 1/22/2024
8.1.2-preview-1 51 1/18/2024
8.1.1 105 1/18/2024
8.1.0 87 1/18/2024
8.0.3 125 12/29/2023
8.0.1 115 12/14/2023
8.0.0 129 12/7/2023
6.0.4.3 111 12/29/2023
6.0.4.2 138 12/20/2023
6.0.4.1 203 12/19/2023
6.0.4 141 12/4/2023
6.0.3.20 123 11/27/2023
6.0.3.19 142 11/22/2023