Prodot.Patterns.Cqrs is a set of libraries that aim to ease the implementation of a CQRS data access and logic pattern. In it's implementation details, it is similar to a Mediator pattern or the request processing pipeline of ASP.Net Core.
- Install the packages
- For Query-only projects, install the Prodot.Patterns.Cqrs.Abstractions NuGet package. For your application project, use Prodot.Patterns.Cqrs
- Define your queries
- Define your queries and commands using the
IQuery<TResult, TSelf>
andCommand<TSelf>
types.
- Define your queries and commands using the
- Implement your query handlers
- Implement your query handlers using the
IQueryHandler<TQuery, TResult>
and (if required)IConfigurableQueryHandler<TConfiguration>
interfaces.- If you want to enable CRUD-style queries using EF Core, you can use the base classes from Prodot.Patterns.Cqrs.EfCore (and the query base classes from Prodot.Patterns.Cqrs.EfCore.Abstractions)
- Implement your query handlers using the
- Register the pipelines
- Register your pipelines using
IPipelineProfile
andPipelineBuilder
.
- Register your pipelines using
- Use the query processor
- Implement
IQueryHandlerFactory
specific to your DI container. Use that andQueryHandlerRegistry
to create aQueryProcessor
.- If you are using
Microsoft.Extensions.DependencyInjection.ServiceCollection
, there is a ready-to-use implementation in Prodot.patterns.Cqrs.MicrosoftExtensionsDependencyInjection
- If you are using
- Use the
IQueryProcessor
to run your queries
- Implement
The solution contained within this repository can be built and tested from within Visual Studio 2022 or later.
If you want to contribute, feel free to reach out to Tim Vinkemeier :)