Ignoring the ResolveUsing
overloads that take an IValueResolver, and looking only at these 2 methods:
void ResolveUsing(Func<TSource, object> resolver);
void MapFrom<TMember>(Expression<Func<TSource, TMember>> sourceMember);
The main difference between these 2 seems to be that ResolveUsing
takes a Func<TSource, object>
, whereas MapFrom takes an Expression<Func<TSource, TMember>>
.
However in client code that actually uses one of these methods with a lambda expression, they seem to be interchangeable:
Mapper.CreateMap<SourceType, DestType>() // uses ResolveUsing
.ForMember(d => d.DestPropX, o => o.ResolveUsing(s => s.SourcePropY));
Mapper.CreateMap<SourceType, DestType>() // uses MapFrom
.ForMember(d => d.DestPropX, o => o.MapFrom(s => s.SourcePropY));
So what ultimately is the difference between the above 2 choices? Is one faster than the other? Is one a better choice than the other and if so, when / why?
See Question&Answers more detail:os