How to skip the mapping between properties of a source and a target object in AutoMapper
As I did in my previous article, I focus again on the AutoMapper framework.
When I map one object to another, I often deal with a destination object that contains LESS properties than the source object. If I take no action, an exception is going to be thrown. For that we will have to declare the skipped properties by using the DoNotValidate method when we define the mapping (CreateMap) between the two objects:
In the case where the destination object contains MORE properties than the source object, we can use the Ignore method:
I hope this is going to help some of you, since chances are you will have to deal with mapping of objects that are do not contain the same number of properties.