2023-11-04 16:45:41 -04:00
> This project was originally initiated by [Powered Software Inc.](https://poweredsoft.com/) and was forked from the [PoweredSoft.CQRS](https://github.com/PoweredSoft/CQRS) Repository
2023-11-04 16:08:39 -04:00
2021-02-02 12:34:18 -05:00
# CQRS
2023-11-04 16:08:39 -04:00
Our implementation of query and command responsibility segregation (CQRS).
2021-02-02 12:34:18 -05:00
## Getting Started
> Install nuget package to your awesome project.
2024-12-22 23:16:48 -05:00
| Package Name | NuGet | NuGet Install |
|-----------------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-----------------------------------------------------------------------:|
| OpenHarbor.CQRS | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS/) | ```dotnet add package OpenHarbor.CQRS ``` |
| OpenHarbor.CQRS.AspNetCore | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.AspNetCore.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.AspNetCore/) | ```dotnet add package OpenHarbor.CQRS.AspNetCore ``` |
| OpenHarbor.CQRS.FluentValidation | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.FluentValidation.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.FluentValidation/) | ```dotnet add package OpenHarbor.CQRS.FluentValidation ``` |
| OpenHarbor.CQRS.DynamicQuery | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.DynamicQuery.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.DynamicQuery/) | ```dotnet add package OpenHarbor.CQRS.DynamicQuery ``` |
| OpenHarbor.CQRS.DynamicQuery.AspNetCore | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.DynamicQuery.AspNetCore.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.DynamicQuery.AspNetCore/) | ```dotnet add package OpenHarbor.CQRS.DynamicQuery.AspNetCore ``` |
2023-11-04 16:45:41 -04:00
> Abstractions Packages.
2024-12-22 23:16:48 -05:00
| Package Name | NuGet | NuGet Install |
| ---------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -----------------------------------------------------: |
| OpenHarbor.CQRS.Abstractions | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.Abstractions.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.Abstractions/) | ```dotnet add package OpenHarbor.CQRS.Abstractions ``` |
| OpenHarbor.CQRS.AspNetCore.Abstractions | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.AspNetCore.Abstractions.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.AspNetCore.Abstractions/) | ```dotnet add package OpenHarbor.CQRS.AspNetCore.Abstractions ``` |
| OpenHarbor.CQRS.DynamicQuery.Abstractions | [![NuGet ](https://img.shields.io/nuget/v/OpenHarbor.CQRS.DynamicQuery.Abstractions.svg?style=flat-square&label=nuget )](https://www.nuget.org/packages/OpenHarbor.CQRS.DynamicQuery.Abstractions/) | ```dotnet add package OpenHarbor.CQRS.AspNetCore.Abstractions ``` |
2021-02-02 12:41:38 -05:00
## Sample of startup code for aspnetcore MVC
```csharp
public void ConfigureServices(IServiceCollection services)
{
2024-08-25 12:40:59 -04:00
// make sure to add your queries and commands before configuring MvCBuilder with .AddOpenHarborCommands and .AddOpenHarborQueries
2021-02-02 12:41:38 -05:00
AddQueries(services);
AddCommands(services);
// adds the non related to aspnet core features.
2023-11-04 16:45:41 -04:00
services.AddOpenHarborCQRS();
2021-02-02 12:41:38 -05:00
services
.AddControllers()
2023-11-04 16:45:41 -04:00
.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)
2021-02-02 12:41:38 -05:00
.AddFluentValidation();
services.AddSwaggerGen();
}
```
2021-02-02 12:42:44 -05:00
> Example how to add your queries and commands.
```csharp
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>();
}
```
2023-11-08 22:54:32 -05:00
2021-08-11 17:14:26 -04:00
# Fluent Validation
2021-02-02 12:41:38 -05:00
2021-08-11 17:14:26 -04:00
We use fluent validation in all of our projects, but we don't want it to be enforced.
2024-08-25 12:40:59 -04:00
If you install ```OpenHarbor.CQRS.FluentValidation``` you can use this way of registrating your commands.
2021-08-11 17:14:26 -04:00
2021-08-11 17:15:34 -04:00
```csharp
2021-08-11 17:15:16 -04:00
public void ConfigureServices(IServiceCollection services)
{
// without Package.
services.AddCommand< EchoCommand , string , EchoCommandHandler > ();
services.AddTransient< IValidator < EchoCommand > , EchoCommandValidator>();
}
2021-08-11 17:14:26 -04:00
2021-08-11 17:15:16 -04:00
public void ConfigureServices(IServiceCollection services)
{
2024-08-25 12:42:54 -04:00
// with OpenHarbor.CQRS.FluentValidation package.
2024-08-25 12:40:59 -04:00
services.AddCommand< EchoCommand , string , EchoCommandHandler , EchoCommandValidator > ();
2021-08-11 17:15:16 -04:00
}
2021-08-11 17:14:26 -04:00
```
2023-11-08 22:54:32 -05:00
# 2024 Roadmap
2023-11-08 22:57:59 -05:00
| Task | Description | Status |
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|--------|
| Support .NET 8 | Ensure compatibility with .NET 8. | ✅ |
| Create a new demo project as an example | Develop a new demo project to serve as an example for users. | ⬜️ |
| New Independent Module for MVC | Develop a standalone module, independent of MVC, to enhance framework flexibility. | ⬜️ |
| Implement .NET Native Compilation (AOT) | Enable Ahead-of-Time (AOT) compilation support for .NET 8. | ⬜️ |
| Update FluentValidation | Upgrade FluentValidation to the latest version, addressing potential breaking changes. | ⬜️ |
| Create a website for the Framework | Develop a website to host comprehensive documentation for the framework. | ⬜️ |
| Re-add support for GraphQL | Re-integrate support for GraphQL, exploring lightweight solutions. | ⬜️ |