Automapper 5, only map matching properties

Sometimes you need a simpler version of an object with only a few properties. You can manually ignore properties but this can be long winded on bigger classes. In AutoMapper 5 you can pass in the destination type in the CreateMap consructor to define only the properties on the destination target are mapped like so:

Mapper.CreateMap<destinationModel, sourceModel>(MemberList.Destination);

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.