.github/workflows | ||
OpenHarbor.CQRS | ||
OpenHarbor.CQRS.Abstractions | ||
OpenHarbor.CQRS.AspNetCore | ||
OpenHarbor.CQRS.AspNetCore.Abstractions | ||
OpenHarbor.CQRS.DynamicQuery | ||
OpenHarbor.CQRS.DynamicQuery.Abstractions | ||
OpenHarbor.CQRS.DynamicQuery.AspNetCore | ||
OpenHarbor.CQRS.FluentValidation | ||
.gitattributes | ||
.gitignore | ||
azure-pipeline.yaml | ||
LICENSE | ||
OpenHarbor.CQRS.sln | ||
README.md |
This project was originally initiated by Powered Software Inc. and was forked from the PoweredSoft.CQRS Repository
CQRS
Our implementation of query and command responsibility segregation (CQRS).
Getting Started
Install nuget package to your awesome project.
Abstractions Packages.
Sample of startup code for aspnetcore MVC
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.AddOpenHarborCQRS();
services
.AddControllers()
.AddOpenHarborQueries() // adds queries to aspnetcore mvc.(you can make it configurable to load balance only commands on a instance)
.AddOpenHarborCommands() // 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.
private void AddCommands(IServiceCollection services)
{
services.AddCommand<CreatePersonCommand, CreatePersonCommandHandler>();
services.AddTransient<IValidator<CreatePersonCommand>, CreatePersonCommandValidator>();
services.AddCommand<EchoCommand, string, EchoCommandHandler>();
services.AddTransient<IValidator<EchoCommand>, EchoCommandValidator>();
}
private void AddQueries(IServiceCollection services)
{
services.AddQuery<PersonQuery, IQueryable<Person>, 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.
public void ConfigureServices(IServiceCollection services)
{
// without Package.
services.AddCommand<EchoCommand, string, EchoCommandHandler>();
services.AddTransient<IValidator<EchoCommand>, EchoCommandValidator>();
}
public void ConfigureServices(IServiceCollection services)
{
// with PoweredSoft.CQRS.FluentValidation package.
services.AddCommandWithValidator<EchoCommand, string, EchoCommandHandler, EchoCommandValidator>();
}