Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jincod/jincod.cqrs

Interfaces for develop app using CQRS principle
https://github.com/jincod/jincod.cqrs

cqrs dotnet dotnet-core

Last synced: about 5 hours ago
JSON representation

Interfaces for develop app using CQRS principle

Awesome Lists containing this project

README

        

# Jincod.CQRS

[![Build status](https://ci.appveyor.com/api/projects/status/mieoljc0aj53765m?svg=true)](https://ci.appveyor.com/project/jincod/jincod-cqrs)
[![NuGet](https://img.shields.io/nuget/v/jincod.cqrs.svg)](https://www.nuget.org/packages/Jincod.CQRS)

Interfaces for develop app using CQRS principle

## Installation

NuGet package [Jincod.CQRS](https://www.nuget.org/packages/Jincod.CQRS)

```PowerShell
Install-Package Jincod.CQRS
```
or

```bash
dotnet add package Jincod.CQRS
```

## Usage

### Query

QueryContext

```csharp
public class SimpleQueryContext : IQueryContext
{
}
```

Query

```csharp
public class SimpleQuery : IQuery
{
public Task ExecuteAsync(SimpleQueryContext queryContext)
{
return Task.FromResult(new SimpleEntity { Name = "Simple1" });
}
}
```

QueryProcessor

```csharp
var queryProcessor = container.Resolve();
var context = new SimpleQueryContext();
var simpleEntity = await queryProcessor.ProcessAsync(context);
```

### Commands

Command

```csharp
public class SimpleCommand : ICommand
{
}
```

CommandHandler

```csharp
public class SimpleCommandHandler : ICommandHandler
{
public Task HandleAsync(SimpleCommand command)
{
// do something
return Task.CompletedTask;
}
}
```

CommandProcessor

```csharp
var commandProcessor = container.Resolve();
var simpleCommand = new SimpleCommand();
await commandProcessor.ProcessAsync(simpleCommand);
```

View [Full example](https://github.com/jincod/Jincod.CQRS/tree/master/Example)