Загрузка...

I Removed MediatR – Building Your Own CQRS Handlers in .NET

Get the free Clean Architecture template: https://dub.sh/ca-template
Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: https://bit.ly/3SXlzSt

You've probably heard—MediatR is going commercial.

If you're using it in your Clean Architecture template (like I did), it might be time to explore alternatives. In this video, I’ll walk you through a full MediatR-free CQRS implementation using custom `ICommand`, `IQuery`, and handler interfaces.

✅ We’ll cover:
- Why I decided to remove MediatR
- How to build your own CQRS abstractions
- Replacing ISender with explicit handler injection
- Manual DI vs automatic scanning using [Scrutor](https://www.nuget.org/packages/Scrutor)
- Fully working Command & Query pipeline without third-party libraries

You'll see how to:
- Refactor a .NET API endpoint from MediatR to your own handler
- Register handlers manually and automatically
- Handle generic result types for commands and queries

👉 Want to skip ahead and use the updated template?
Check the pinned comment for a link to the Clean Architecture template without MediatR.

Check out my courses:
https://www.milanjovanovic.tech/courses

Read my Blog here:
https://www.milanjovanovic.tech/blog

Join my weekly .NET newsletter:
https://www.milanjovanovic.tech

Chapters
0:00 Why MediatR and CQRS
1:44 ICommand and IQuery abstractions
4:33 Registering handlers with DI
5:21 Using handlers in endpoints (or services)
7:47 Completing the refactoring
10:32 A better way to register handlers with DI
13:55 The problem with cross-cutting concerns

Видео I Removed MediatR – Building Your Own CQRS Handlers in .NET канала Milan Jovanović
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять