Understanding CQRS Pattern using .NET Core & MediatR

Command and Query Responsibility Segregation with MediatR

Why and When? 🤔

CQRS pattern separates a service’s write tasks(commands) from its read tasks(query).
High level CQRS implementation. You can either have two separate databases for reads and writes (SQL for writes and NoSQL for reads etc.) or one databases for both operations.

Hands On! 👨‍💻

git init
git remote add origin https://github.com/nishanc/CQRSDemoDotNet
git fetch origin 2a48ef328ec5ca1e4db5e8c0a65a6cf918ee6f0f
git reset --hard FETCH_HEAD
dotnet restore
dotnet watch run
dotnet add package MediatR
dotnet add package MediatR.Extensions.Microsoft.DependencyInjection
public class ProductToAddDto {
public string ProductName { get; set; }
public string Description { get; set; }
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));

Systems Design • Social Innovation • Cloud • ML