• Stars
    star
    304
  • Rank 137,274 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 1 month 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#
343
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#
128
star
4

blazor-azure-openai

The Blazor WebAssembly app that inspired the Microsoft //Build 2023 demo app.
C#
93
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

pwned-client

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

MvcAngular2

JavaScript
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

profanity-filter

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

IEvangelist.Blazing.Chuck

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

DotNetDocs.Show

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

IEvangelist.SignalR.Streaming

TypeScript
20
star
17

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

color-game

TypeScript
5
star
27

IEvangelist.BlazingTranslations

C#
5
star
28

IEvangelist.DotNet.Miglifier

HTML
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

xref-helper

TypeScript
2
star
39

IEvangelist.Web.Api

C#
1
star
40

dmp-in-three-debounce

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

CreamCityCodeEmcee

CSS
1
star
42

aspnetcore-workshop

HTML
1
star
43

IEvangelist.TypeScript

TypeScript
1
star
44

SignalR-Talk

CSS
1
star
45

BlazoR.Board

C#
1
star
46

Mentor.Coding.Challenge

C#
1
star
47

profanity-filter-aspire

C#
1
star