IEvangelist.Azure.CosmosRepository 1.0.4

There is a newer version of this package available.
See the version list below for details.
Install-Package IEvangelist.Azure.CosmosRepository -Version 1.0.4
dotnet add package IEvangelist.Azure.CosmosRepository --version 1.0.4
<PackageReference Include="IEvangelist.Azure.CosmosRepository" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IEvangelist.Azure.CosmosRepository --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IEvangelist.Azure.CosmosRepository, 1.0.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install IEvangelist.Azure.CosmosRepository as a Cake Addin
#addin nuget:?package=IEvangelist.Azure.CosmosRepository&version=1.0.4

// Install IEvangelist.Azure.CosmosRepository as a Cake Tool
#tool nuget:?package=IEvangelist.Azure.CosmosRepository&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

NuGet

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 properpty is used internally to manage partitioning on your behalf.

Getting started

  1. Create an Azure Cosmos DB SQL resource.

  2. 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.

  3. Call AddCosmosRepository and provide the apps configuration object:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddCosmosRepository(Configuration);
    }
    

    The optional setupAction allows consumers to manually configure the RepositoryOptions object:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddCosmosRepository(Configuration,
            options => 
            {
                options.CosmosConnectionString = "< connection string >";
                options.ContainerId = "data-store";
                options.DatabaseId = "samples";
            });
    }
    
  4. 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; }
    }
    
  5. Ask for an instance of IRepository<TItem>, in this case the TItem is Person:

    using Microsoft.Azure.CosmosRepository;
    
    public class Consumer
    {
        readonly IRepository<Person> _repository;
    
        public Consumer(IRepository<Person> repository) =>
            _respository = repository;
    
        // Use the repo...
    }
    
  6. Perform any of the operations on the _repository instance, create Person records, update them, read them, or delete.

  7. Enjoy!

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.7.0 293 11/15/2021
2.6.0 184 11/3/2021
2.5.3 462 11/1/2021
2.5.2 708 10/22/2021
2.5.1 208 10/18/2021
2.5.0 1,382 9/23/2021
2.3.0 728 8/18/2021
2.2.0 410 7/20/2021
2.1.9 997 6/11/2021
2.1.6 934 5/10/2021
2.1.5 1,819 2/11/2021
2.1.4 1,418 2/1/2021
2.1.3 6,551 12/11/2020
2.1.2 148 12/2/2020
2.1.1 758 11/19/2020
2.1.0 850 11/10/2020
2.0.3 295 10/23/2020
2.0.2 356 10/12/2020
2.0.1 178 10/12/2020
2.0.0 206 10/9/2020
1.0.5 292 10/8/2020
1.0.4 269 10/7/2020
1.0.1 206 10/2/2020
1.0.0 194 10/1/2020
0.0.2-preview 168 9/30/2020
0.0.1-preview 182 9/17/2020