Added name mappings support #283

wants to merge 2 commits into


None yet

3 participants


Resolves issue #277

This extension allows:
Mapper.CreateMap<Source, Destination>("mapping1")...;
Mapper.CreateMap<Source, Destination>("mapping2")...;

and resolve them:
Mapper.Map<Source, Destination>("mapping1");

jbogard commented Jan 9, 2013

What situation are you seeing where you need multiple maps for the same two types? Is it different sets of mapping behavior?

goodlaff commented Oct 3, 2013

hi jimmy,

a couple of scenarios i have where named mappings have proven useful are with webapi/REST view models and mapping them to entity models, especially when I am trying to maintain a generic type on both controller & service.

firstly, since REST can PATCH partial objects or POST the full object, and both request models are the same viewmodel as far as the api is concerned, named mappings allow me to differentiate in code which mapping to use - basically ignoring certain properties, or taking the destination value for a "Partial" named mapping.

secondly, REST will accept objects with properties that should not be changed in the entity model for PATCH/PUT (date_created, author_id etc) that i would like to ignore, but I would want to set when creating a new entity with POST. so here i would have a "Create" mapping and "Update" mapping.

maybe string names are not the most elegant, a possible better solution could be behaviour or event driven.

i know there are other ways to solve these problems, but the named mappings is a useful solution.


@jbogard jbogard removed this from the v.Future milestone Jan 18, 2016
jbogard commented Jan 28, 2016

So you can take care of this using 4.2.0, that introduces removing of the static interface to instance-based. Now you can partition configuration as much as you want.

@jbogard jbogard closed this Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment