blog16

MediatR & CQRS in .NET

  • As .NET systems grow, most complexity doesnโ€™t come from features. It comes from ๐›๐ฅ๐ฎ๐ซ๐ซ๐ž๐ responsibilities.
  • Thatโ€™s why I use MediatR + CQRS โ€” not as patterns, but as ๐ ๐ฎ๐š๐ซ๐๐ซ๐š๐ข๐ฅ๐ฌ.

What this approach enforces:

  • Controllers express intent only
  • MediatR owns request flow and cross-cutting concerns
  • Queries read, Commands write โ€” never both
  • Each request maps to exactly one handler
  • Read and write models evolve independently
  • The result is code thatโ€™s easier to reason about, test, and change under pressure.

Where CQRS actually helps:

  • Complex domains
  • Read-heavy workloads
  • Performance-sensitive systems
  • Clear separation between consistency and speed

Where not to use CQRS:

  • Simple CRUD applications
  • Small teams unfamiliar with the pattern
  • Systems where eventual consistency adds risk, not value
  • CQRS doesnโ€™t remove complexity; It ๐จ๐ซ๐ ๐š๐ง๐ข๐ณ๐ž๐ฌ ๐ข๐ญ โ€” when the problem is big enough to deserve it.