# 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 | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.CQRS.Abstractions.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.CQRS.Asbtractions/) | ```PM> Install-Package PoweredSoft.CQRS.Abstractions ``` | | PoweredSoft.CQRS | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.CQRS.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.CQRS/) | ```PM> Install-Package PoweredSoft.CQRS ``` | | PoweredSoft.CQRS.FluentValidation | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.CQRS.FluentValidation.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.CQRS.FluentValidation/) | ```PM> Install-Package PoweredSoft.CQRS.FluentValidation ``` | | PoweredSoft.CQRS.AspNetCore.Abstractions | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.CQRS.AspNetCore.Abstractions.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.CQRS.AspNetCore.Abstractions/) | ```PM> Install-Package PoweredSoft.CQRS.AspNetCore.Abstractions ``` | | PoweredSoft.CQRS.AspNetCore | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.CQRS.AspNetCore.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.CQRS.AspNetCore/) | ```PM> Install-Package PoweredSoft.CQRS.AspNetCore ``` | | PoweredSoft.CQRS.GraphQL.HotChocolate | [![NuGet](https://img.shields.io/nuget/v/PoweredSoft.CQRS.GraphQL.HotChocolate.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.CQRS.GraphQL.HotChocolate/) | ```PM> Install-Package PoweredSoft.CQRS.GraphQL.HotChocolate ``` | ## 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(); // enabling gql. services .AddGraphQLServer() .AddProjections() .AddQueryType(d => d.Name("Query")) .AddPoweredSoftQueries() .AddPoweredSoftDynamicQueries() .AddMutationType(d => d.Name("Mutation")) .AddPoweredSoftMutations(); 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>(); } ``` # Fluent Validation We use fluent validation in all of our projects, but we don't want it to be enforced. If you install. ```PoweredSoft.CQRS.FluentValidation``` you can use this way of registrating your commands. ```chsarp public void ConfigureServices(IServiceCollection services) { // without Package. services.AddCommand(); services.AddTransient, EchoCommandValidator>(); } public void ConfigureServices(IServiceCollection services) { // with PoweredSoft.CQRS.FluentValidation package. services.AddCommandWithValidator(); } ```