Interfaces for develop app using CQRS principle
NuGet package Jincod.CQRS
Install-Package Jincod.CQRSor
dotnet add package Jincod.CQRSQueryContext
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);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