Category Archives: MediatR

Dealing with Duplication in MediatR Handlers

We’ve been using MediatR (or some manifestation of it) for a number of years now, and one issue that comes up frequently is “how do I deal with duplication”. In a traditional DDD n-tier architecture, you had: Controller Service Repository … Continue reading 

Also posted in DomainDrivenDesign | 7 Comments

CQRS/MediatR implementation patterns

Early on in the CQRS/ES days, I saw a lot of questions on modeling problems with event sourcing. Specifically, trying to fit every square modeling problem into the round hole of event sourcing. This isn’t anything against event sourcing, but … Continue reading 

Also posted in CQRS, DomainDrivenDesign | 17 Comments

Vertical Slice Test Fixtures for MediatR and ASP.NET Core

One of the nicest side effects of using MediatR is that my controllers become quite thin. Here’s a typical controller: Unit testing this controller is a tad pointless – I’d only do it if the controller actions were doing something … Continue reading 

Also posted in ASPNetCore, Testing | 10 Comments

MediatR Pipeline Examples

A while ago, I blogged about using MediatR to build a processing pipeline for requests in the form of commands and queries in your application. MediatR is a library I built (well, extracted from client projects) to help organize my … Continue reading 

| 31 Comments

MediatR Extensions for Microsoft Dependency Injection Released

To help those building applications using the new Microsoft DI libraries (used in Orleans, ASP.NET Core, etc.), I pushed out a helper package to register all of your MediatR handlers into the container. MediatR.Extensions.Microsoft.DependencyInjection To use, just add the AddMediatR … Continue reading 

Also posted in ASPNetCore | 9 Comments

CQRS with MediatR and AutoMapper

CQRS is a simple pattern – two objects for command/queries where once there was one. These days just about every system I build utilizes CQRS, as it’s a natural progression from refactoring your apps around the patterns arising from reads … Continue reading 

Also posted in Architecture, AutoMapper, CQRS | 65 Comments

Integrating MediatR with Web API

One of the design goals I had in mind with MediatR was to limit the 3rd party dependencies (and work) needed to integrate MediatR. To do so, I only take a dependency on CommonServiceLocator. In MediatR, I need to resolve … Continue reading 

| 26 Comments