File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 33
44namespace MediatorPattern . Command ;
55
6+ // We have to return Unit because "void" is not a valid return type
7+ // With that MediatR can have a uniform and easy API
68public class DeleteAllUsersCommandHandler : IRequestHandler < DeleteAllUsersCommand , Unit >
79{
810 private readonly UserRepository _userRepository ;
Original file line number Diff line number Diff line change 2121ServiceProvider CreateServiceProvider ( )
2222{
2323 var collection = new ServiceCollection ( ) ;
24+ // This will execute our main logic
2425 collection . AddScoped < Execution > ( ) ;
26+
27+ // This comes from the MediatR package.
28+ // It looks for all commands, queries and handlers and registers
29+ // them in the container
2530 collection . AddMediatR ( typeof ( Program ) . Assembly ) ;
31+
32+ // Our repository
2633 collection . AddScoped < UserRepository > ( ) ;
2734 return collection . BuildServiceProvider ( ) ;
2835}
Original file line number Diff line number Diff line change 1+ # Mediator Pattern - CQRS with MediatR
2+
3+ The famous mediator pattern. Used so often especially in combination with ** CQRS** .
4+
5+ In this article I will show how the mediator pattern itself works, what ** CQRS** is and its advantages.
6+ For that we will write a small application, which demonstrates how to use the pattern and what we gain from using it.
7+
8+ Found [ here] ( https://steven-giesel.com/blogPost/064ca62a-b384-45da-9212-4c3840e5ba9c )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Contains all of my examples from various blog posts. You can find a comprehensiv
44
55| BlogPost | Publish Date |
66| ---------------------------------------------------------------------------------------- | ------------ |
7+ | [ Mediator Pattern - CQRS with MediatR] ( MediatorPattern/ ) | 06.08.2022 |
78| [ Logging Source Code Generators] ( LoggingSourceCodeGenerator/ ) | 27.07.2022 |
89| [ Blazor Client - Loading Screen] ( BlazorClientLoadingScreen/ ) | 12.07.2022 |
910| [ Central nuget store for your UNO Platform App] ( UnoDirectoryBuildProps/ ) | 23.06.2022 |
You can’t perform that action at this time.
0 commit comments