File tree 4 files changed +18
-0
lines changed
4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 3
3
4
4
namespace MediatorPattern . Command ;
5
5
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
6
8
public class DeleteAllUsersCommandHandler : IRequestHandler < DeleteAllUsersCommand , Unit >
7
9
{
8
10
private readonly UserRepository _userRepository ;
Original file line number Diff line number Diff line change 21
21
ServiceProvider CreateServiceProvider ( )
22
22
{
23
23
var collection = new ServiceCollection ( ) ;
24
+ // This will execute our main logic
24
25
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
25
30
collection . AddMediatR ( typeof ( Program ) . Assembly ) ;
31
+
32
+ // Our repository
26
33
collection . AddScoped < UserRepository > ( ) ;
27
34
return collection . BuildServiceProvider ( ) ;
28
35
}
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
4
4
5
5
| BlogPost | Publish Date |
6
6
| ---------------------------------------------------------------------------------------- | ------------ |
7
+ | [ Mediator Pattern - CQRS with MediatR] ( MediatorPattern/ ) | 06.08.2022 |
7
8
| [ Logging Source Code Generators] ( LoggingSourceCodeGenerator/ ) | 27.07.2022 |
8
9
| [ Blazor Client - Loading Screen] ( BlazorClientLoadingScreen/ ) | 12.07.2022 |
9
10
| [ Central nuget store for your UNO Platform App] ( UnoDirectoryBuildProps/ ) | 23.06.2022 |
You can’t perform that action at this time.
0 commit comments