Skip to content

jincod/Jincod.CQRS

Repository files navigation

Jincod.CQRS

Build status NuGet

Interfaces for develop app using CQRS principle

Installation

NuGet package Jincod.CQRS

Install-Package Jincod.CQRS

or

dotnet add package Jincod.CQRS

Usage

Query

QueryContext

public class SimpleQueryContext : IQueryContext<SimpleEntity>
{
}

Query

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

QueryProcessor

var queryProcessor = container.Resolve<IQueryProcessor>();
var context = new SimpleQueryContext();
var simpleEntity = await queryProcessor.ProcessAsync<SimpleEntity, SimpleQueryContext>(context);

Commands

Command

public class SimpleCommand : ICommand
{
}

CommandHandler

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

CommandProcessor

var commandProcessor = container.Resolve<ICommandProcessor>();
var simpleCommand = new SimpleCommand();
await commandProcessor.ProcessAsync(simpleCommand);

View Full example

About

Interfaces for develop app using CQRS principle

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published