Go to file
Mathias Beaulieu-Duncan ad0d84f00b update documentation
2023-11-04 16:45:41 -04:00
.github/workflows Update dotnet.yml 2023-11-04 16:21:46 -04:00
OpenHarbor.CQRS update namespaces 2023-11-04 15:24:56 -04:00
OpenHarbor.CQRS.Abstractions update namespaces 2023-11-04 15:24:56 -04:00
OpenHarbor.CQRS.AspNetCore update doc a little bit and change PoweredSoft to OpenHarbor in a few methods 2023-11-04 16:08:39 -04:00
OpenHarbor.CQRS.AspNetCore.Abstractions update namespaces 2023-11-04 15:24:56 -04:00
OpenHarbor.CQRS.DynamicQuery update namespaces 2023-11-04 15:24:56 -04:00
OpenHarbor.CQRS.DynamicQuery.Abstractions update namespaces 2023-11-04 15:24:56 -04:00
OpenHarbor.CQRS.DynamicQuery.AspNetCore update doc a little bit and change PoweredSoft to OpenHarbor in a few methods 2023-11-04 16:08:39 -04:00
OpenHarbor.CQRS.FluentValidation update namespaces 2023-11-04 15:24:56 -04:00
.gitattributes Add .gitignore and .gitattributes. 2021-02-01 23:31:05 -05:00
.gitignore Add .gitignore and .gitattributes. 2021-02-01 23:31:05 -05:00
azure-pipeline.yaml Update azure-pipeline.yaml for Azure Pipelines 2021-02-07 00:25:20 -05:00
LICENSE Create LICENSE 2021-02-01 23:55:58 -05:00
OpenHarbor.CQRS.sln update namespaces 2023-11-04 15:24:56 -04:00
README.md update documentation 2023-11-04 16:45:41 -04:00

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.

Full Version NuGet NuGet Install
OpenHarbor.CQRS NuGet PM> Install-Package OpenHarbor.CQRS
OpenHarbor.CQRS.AspNetCore NuGet PM> Install-Package OpenHarbor.CQRS.AspNetCore
OpenHarbor.CQRS.FluentValidation NuGet PM> Install-Package OpenHarbor.CQRS.FluentValidation
OpenHarbor.CQRS.DynamicQuery NuGet PM> Install-Package OpenHarbor.CQRS.DynamicQuery
OpenHarbor.CQRS.DynamicQuery.AspNetCore NuGet PM> Install-Package OpenHarbor.CQRS.DynamicQuery.AspNetCore

Abstractions Packages.

Full Version NuGet NuGet Install
OpenHarbor.CQRS.Abstractions NuGet PM> Install-Package OpenHarbor.CQRS.Abstractions
OpenHarbor.CQRS.AspNetCore.Abstractions NuGet PM> Install-Package OpenHarbor.CQRS.AspNetCore.Abstractions
OpenHarbor.CQRS.DynamicQuery.Abstractions NuGet PM> Install-Package OpenHarbor.CQRS.AspNetCore.Abstractions

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>();
}