Is there a way to tell AutoMapper to ignore all of the properties except the ones which are mapped explicitly?
I have external DTO classes which are likely to change from the outside and I want to avoid specifying each property to be ignored explicitly, since adding new properties will break the functionality (cause exceptions) when trying to map them into my own objects.
In version of 3.3.1 you simply can use
IgnoreAllPropertiesWithAnInaccessibleSetter()
orIgnoreAllSourcePropertiesWithAnInaccessibleSetter()
methods.I've been able to do this the following way:
Note: I'm using AutoMapper v.2.0.
I know this is an old question, but @jmoerdyk in your question:
you can use this answer like this inside the Profile ctor
There's been a few years since the question has been asked, but this extension method seems cleaner to me, using current version of AutoMapper (3.2.1):