5

Simple question but cant seem to find the answer. Can I apply .ForAllMembers(options => options.Condition(c => !c.IsSourceValueNull)); globally in the configuration so I dont have to apply it to all of my objects?

Thanks!

Mike
  • 5,437
  • 7
  • 45
  • 62

1 Answers1

0

Create a global mapper configuration:

new MapperConfiguration(cfg =>
{
    Func<object, object, object, bool> condition = (src, dest, sourceMember) => sourceMember != null;
    cfg.ForAllMaps(((map, expression) => expression.ForAllMembers(opt => opt.Condition(condition))));
});

Tested with Automapper 9.