Jincod.CQRS
02 Feb 2015Interfaces for for develop app using CQRS principle
Installation
Available on NuGet
PM>Install-Package Jincod.CQRS
Query
QueryContext
public class SimpleQueryContext : IQueryContext<SimpleEntity>
{
}
Query
public class SimpleQuery : IQuery<SimpleQueryContext, SimpleEntity>
{
public SimpleEntity Execute(SimpleQueryContext queryContext)
{
return new SimpleEntity {Name = "Simpl1"};
}
}
QueryProcessor
var queryProcessor = container.Resolve<IQueryProcessor>();
var context = new SimpleQueryContext();
SimpleEntity simpleEntity = queryProcessor.Process<SimpleEntity, SimpleQueryContext>(context);
Commands
Command
public class SimpleCommand : ICommand
{
}
CommandHandler
public class SimpleCommandHandler : ICommandHandler<SimpleCommand>
{
public void Handle(SimpleCommand command)
{
// do something
}
}
CommandProcessor
var commandProcessor = container.Resolve<ICommandProcessor>();
var simpleCommand = new SimpleCommand();
commandProcessor.Process(simpleCommand);