Implementing CQRS
Here are the steps on how to use the MediatR
package in the ASP.NET Core application. The task of the MediatR
package is to help you implement both the CQRS and Mediator patterns with ease.
Let's clean up our solution first by deleting all the Class1.cs
files you can find in the application. The Class1.cs
files were generated when we created the projects.
Adding the MediatR package
We are now going to install the MediatR
package:
- Navigate to your
Travel.Application
project using thedotnet
CLI. Then we need to install some NuGet packages by running the following commands:dotnet add package MediatR
The preceding command installs the mediator implementation in .NET into the
Travel.Application
project.The following command installs the
MediatR
extensions for ASP.NET Core:dotnet add package MediatR.Extensions.Microsoft.DependencyInjection
The following command installs the logging abstractions for
Microsoft.Extensions.Logging
:dotnet add package Microsoft...