AutoMapper LINQ Support Deep Dive

My favorite feature of AutoMapper is its LINQ support. If you're using AutoMapper, and not using its queryable extensions, you're missing out! Normal AutoMapper usage is something like: var dest = _mapper.Map<Dest>(source); Which would be equivalent to: var dest = new Dest { Thing = source.Thing, Thing2 = source.Thing2, FooBarBaz = source.Foo?.Bar?.Baz }; The main problem people run into here is that typically that source object is [Read More]

AutoMapper 9.0 Released

As with the other major releases of AutoMapper, this one introduces breaking API changes with relatively few other additions. The major breaking changes (see upgrade guide for details) include: Removing the static API Removing "dynamic" maps (automatically created maps) Fix on IMappingAction to include a ResolutionContext parameter The motivation behind removing the static API is that most new users to AutoMapper will do so through the DI extensions packages, using [Read More]

AutoMapper 8.1.0 Released

Today we released AutoMapper 8.1.0: Upgrade Guide for 8.0 Release Notes AutoMapper 8.1 adds a major new feature - attribute-based maps. Attribute maps let you easily declare maps on destination types when you have straightforward scenarios. Instead of: public class OrderProfile { public OrderProfile() { CreateMap<Order, OrderIndexModel>(); CreateMap<Order, OrderEditModel>(); CreateMap<Order, OrderCreateModel>(); } } You can declare your type maps directly on [Read More]

AutoMapper's Design Philosophy

While a lot of people use AutoMapper, and love it, I meet just as many people that hate it. When I hear their stories, it becomes clear to me that it's not that AutoMapper was "abused" per se, but that it was used without understanding why AutoMapper exists and what problems it was designed to solve. AutoMapper originated at the beginning of a large MVC application way back in the [Read More]

AutoMapper Usage Guidelines

Configuration √ DO initialize AutoMapper once with Mapper.Initialize at AppDomain startup in legacy ASP.NET AutoMapper's static initialization is designed to build configuration once, and cache it. √ DO use the AutoMapper.Extensions.Microsoft.DependencyInjection package in ASP.NET Core with services.AddAutoMapper(assembly[]) The extensions package will perform all the scanning and dependency injection registration. You only need to declare Profile configuration. X DO NOT call CreateMap on each request [Read More]