• Stars
    star
    298
  • Rank 138,965 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Wraps the .NET SDK for Azure Cosmos DB abstracting away the complexity, exposing a simple CRUD-based repository pattern

build CodeQL NuGet Nuget .NET code metrics Discord

All Contributors

Azure Cosmos DB Repository .NET SDK

This package wraps the NuGet: Microsoft.Azure.Cosmos package, exposing a simple dependency-injection enabled IRepository<T> interface.

Documentation

The core library IEvangelist.Azure.CosmosRepository and IEvangelist.Azure.CosmosEventSourcing both host there own documentation site. See below:

Cosmos Repository

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

  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:

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

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

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddCosmosRepository(
            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) =>
            _repository = 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!

Samples

Visit the Microsoft.Azure.CosmosRepository.Samples directory for samples on how to use the library with:

Deep-dive video

A deep dive into the Azure Cosmos DB repository pattern NET SDK

Cosmos Repository Crash Course

Discord

Get extra support on our dedicated Discord channel.

alt Join the conversation

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

David Pine
David Pine

๐Ÿ’ป โš ๏ธ ๐Ÿ’ก ๐Ÿ‘€
Invvard
Invvard

โš ๏ธ ๐Ÿ’ป
Richard Mercer
Richard Mercer

๐Ÿ’ป
Daniel Marbach
Daniel Marbach

๐Ÿ’ป
Manuel Sidler
Manuel Sidler

๐Ÿ’ป
Dave Brock
Dave Brock

๐Ÿ“– ๐Ÿ’ป
Cagdas Erman Afacan
Cagdas Erman Afacan

๐Ÿ’ป ๐Ÿ’ก
dcuccia
dcuccia

๐Ÿ’ป
VeryCautious
VeryCautious

๐Ÿ’ป โš ๏ธ
Billy Mumby
Billy Mumby

๐Ÿ’ป ๐Ÿ“– ๐Ÿค”
Michael Zhang
Michael Zhang

๐Ÿค” ๐Ÿ’ป
Shay Rojansky
Shay Rojansky

๐Ÿ‘€
Junior Macedo
Junior Macedo

๐Ÿ’ป ๐Ÿค”
Emre KARA
Emre KARA

๐Ÿ’ป
Brad Westness
Brad Westness

๐Ÿ‘€
Matt Stannett
Matt Stannett

๐Ÿ’ป ๐Ÿ“– โš ๏ธ
mustafarabie
mustafarabie

๐Ÿ’ป โš ๏ธ
Robert Bennett
Robert Bennett

โš ๏ธ ๐Ÿ’ป
Rabosa616
Rabosa616

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Adam Storr
Adam Storr

๐Ÿ’ป โš ๏ธ
Kevin Benton
Kevin Benton

๐Ÿ’ป โš ๏ธ
Filip Persson
Filip Persson

๐Ÿ’ป โš ๏ธ
A.F.M. Noorullah
A.F.M. Noorullah

๐Ÿ“–
Ion Dormenco
Ion Dormenco

๐Ÿ’ป
Martin Oehlert
Martin Oehlert

๐Ÿ’ป
Evan Johnson
Evan Johnson

๐Ÿ’ป โš ๏ธ
Phil Reed
Phil Reed

โš ๏ธ ๐Ÿ’ป
dnitsch
dnitsch

๐Ÿค”
Sean Farrow
Sean Farrow

๐Ÿค”

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

blazorators

This project converts TypeScript type declarations into C# representations, and use C# source generators to expose automatic JavaScript interop functionality.
C#
331
star
2

signalr-chat

A chat app built with Blazor WebAssembly, hosted on ASP.NET Core, with the latest C# and SignalR -- need I say more?
C#
160
star
3

learning-blazor

The application for the "Learning Blazor: Build Single Page Apps with WebAssembly and C#" O'Reilly Media book by David Pine.
C#
125
star
4

blazor-azure-openai

The Blazor WebAssembly app that inspired the Microsoft //Build 2023 demo app.
C#
87
star
5

IEvangelist.VideoChat

Imagine two Twilio SDKs, ASP.NET Core/C#, Angular/TypeScript, SignalR, etc... Yeah, amazing!
CSS
67
star
6

dotnet-github-actions-sdk

The unofficial GitHub ToolKit for developing GitHub Actions with .NET.
C#
55
star
7

resource-translator

A GitHub Action that automatically creates machine-translated PRs of translation files. Supported file formats include, .ini, .po, .restext, .resx, .xliff .json.
TypeScript
52
star
8

Mirror

Magic mirror application. Written with C# .NET, UWP. For presentation @ MKE DOT NET 2016.
C#
46
star
9

MvcAngular2

JavaScript
32
star
10

pwned-client

A .NET 8.0 HTTP client library for the "';-- Have I Been Pwned" API: https://haveibeenpwned.com/api/v3
C#
32
star
11

Blazing.Twilio.Video

A Blazor Wasm video chat app, built using the Twilio SDK for .NET and TypeScript.
C#
26
star
12

IEvangelist.BlazoR.TwitterStreaming

Yes, #Blazor which is C# in the web browser + SignalR real-time army + Live @Twitter streaming... holy cats batman!
C#
22
star
13

IEvangelist.Blazing.Chuck

If you like #Blazor, C# .NET running on the browser and Chuck Norris -- look no further.
CSS
21
star
14

DotNetDocs.Show

The .NET docs stream / show website
C#
20
star
15

IEvangelist.SignalR.Streaming

TypeScript
20
star
16

Blazing.DotNet.Tweets

Yes, #Blazor which is C# in the web browser + SignalR real-time army + Live @Twitter streaming... holy cats batman!
C#
20
star
17

profanity-filter

Potty Mouth: A GitHub Action profanity filter written in .NET, leveraging Native AOT compilation.
C#
19
star
18

IEvangelist.PhotoBooth

An Angular application with ASP.NET Core/C# and a bit of magic -- enter the photo booth, and share your animated images on social media!
C#
18
star
19

orleans-shopping-cart

C#
15
star
20

GitHub.ProfanityFilter

An Azure function to handle a GitHub webhook, which will take action on issues/pull requests that contain profanity.
C#
10
star
21

orleans-on-container-apps

C#
9
star
22

IEvangelist

7
star
23

actions-demo

A demo repository showing GitHub Actions that build and deploy a Blazor app.
HTML
6
star
24

pathological.globbing

.NET globbing libraryโ€”built atop Microsoft.Extensions.FileSystemGlobbing.
C#
6
star
25

DocFX.Repository.Sweeper

C#
6
star
26

IEvangelist.BlazingTranslations

C#
5
star
27

IEvangelist.DotNet.Miglifier

HTML
5
star
28

color-game

TypeScript
5
star
29

IEvangelist.AspNetCore.Optimization

C#
4
star
30

IEvangelist.Slack.SlashCommands

C#
3
star
31

csharp-eight

C#
3
star
32

orleans-template

GitHub repository template for Microsoft Orleans
C#
3
star
33

IEvangelist.Retweet

C#
2
star
34

learn-hugo

HTML
2
star
35

asp.net-core-minimal-apis-course

Learn how to create ASP.NET Core Minimal APIs.
2
star
36

alias-any-type

A demo app, intended to demonstrate "alias any type" from C# 12.
C#
2
star
37

nasa-mobile

C#
2
star
38

IEvangelist.Web.Api

C#
1
star
39

dmp-in-three-debounce

DMP in 3: RxJS Debounce Example Project
TypeScript
1
star
40

CreamCityCodeEmcee

CSS
1
star
41

aspnetcore-workshop

HTML
1
star
42

IEvangelist.TypeScript

TypeScript
1
star
43

SignalR-Talk

CSS
1
star
44

BlazoR.Board

C#
1
star
45

Mentor.Coding.Challenge

C#
1
star
46

profanity-filter-aspire

C#
1
star