# CQRS
Our implementation of query and command responsability segregation (CQRS).
## Getting Started
> Install nuget package to your awesome project.
| Full Version | NuGet | NuGet Install |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -----------------------------------------------------: |
| PoweredSoft.CQRS.Abstractions | [](https://www.nuget.org/packages/PoweredSoft.CQRS.Asbtractions/) | ```PM> Install-Package PoweredSoft.CQRS.Abstractions ``` |
| PoweredSoft.CQRS | [](https://www.nuget.org/packages/PoweredSoft.CQRS/) | ```PM> Install-Package PoweredSoft.CQRS ``` |
| PoweredSoft.CQRS.AspNetCore.Abstractions | [](https://www.nuget.org/packages/PoweredSoft.CQRS.AspNetCore.Abstractions/) | ```PM> Install-Package PoweredSoft.CQRS.AspNetCore.Abstractions ``` |
| PoweredSoft.CQRS.AspNetCore | [](https://www.nuget.org/packages/PoweredSoft.CQRS.AspNetCore/) | ```PM> Install-Package PoweredSoft.CQRS.AspNetCore ``` |
## Sample of startup code for aspnetcore MVC
```csharp
public void ConfigureServices(IServiceCollection services)
{
// make sure to add your queries and commands before the .AddPoweredSoftQueries and .AddPoweredSoftCommands
AddQueries(services);
AddCommands(services);
// adds the non related to aspnet core features.
services.AddPoweredSoftCQRS();
services
.AddControllers()
.AddPoweredSoftQueries() // adds queries to aspnetcore mvc.(you can make it configurable to load balance only commands on a instance)
.AddPoweredSoftCommands() // adds commands to aspnetcore mvc. (you can make it configurable to load balance only commands on a instance)
.AddFluentValidation();
services.AddSwaggerGen();
}
```
> Example how to add your queries and commands.
```csharp
private void AddCommands(IServiceCollection services)
{
services.AddCommand();
services.AddTransient, CreatePersonCommandValidator>();
services.AddCommand();
services.AddTransient, EchoCommandValidator>();
}
private void AddQueries(IServiceCollection services)
{
services.AddQuery, PersonQueryHandler>();
}
```