In AutoMapper 2.2.1, is there a way to configure my mappings so that when an property is not explicitly ignored, an exception is thrown? For example, I have the following classes and configuration:
public class Source { public int X { get; set; } public int Y { get; set; } public int Z { get; set; } } public class Destination { public int X { get; set; } public int Y { get; set; } }
The behavior I get with this configuration is that the Destination.X and Destination.Y properties are set. Also, if I check my configuration:
Mapper.AssertConfigurationIsValid();
Then I will not get any display exceptions. I would like AutoMapperConfigurationException be thrown because Source.Z is not explicitly ignored.
I would like for me to explicitly ignore the Z property, so that AssertConfiguartionIsValid without exception:
Mapper.CreateMap<Source, Destination>() .ForSourceMember(m => mZ, e => e.Ignore());
AutoMapper does not currently throw an exception. I would like it to throw an exception if I don't explicitly specify Ignore . How can i do this?
Mike bailey
source share