简单的问题,但似乎找不到答案。是否可以在配置中全局应用.ForAllMembers(options => options.Condition(c => !c.IsSourceValueNull));
,所以不必将其应用于所有对象?
谢谢!
创建全局映射器配置:
new MapperConfiguration(cfg =>
{
Func<object, object, object, bool> condition = (src, dest, sourceMember) => sourceMember != null;
cfg.ForAllMaps(((map, expression) => expression.ForAllMembers(opt => opt.Condition(condition))));
});
使用Automapper 9测试。