We're using ViewModels based on a special class that has a few properties. These properties don't have mapping properties in the models. How can I tell AutoMapper to ignore these properties globally? This is what I tried but I still get errors related to these properties. Also, is there a way to pass multiple properties to be ignored in the CreateMap?
public class AutoMapperConfig
{
public static MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg =>
{
cfg.AddProfile(new MappingProfile());
cfg.ShouldMapProperty = pi => !pi.Name.InList("HiddenSwitch","ErrorMessage",
"SuccessMessage", "WarningMessage","DuplicateForm");
});
public static IMapper Mapper;
public static void Configure()
{
Mapper = mapperConfiguration.CreateMapper();
mapperConfiguration.AssertConfigurationIsValid();
}
}