Does AutoMapper MapFrom work for calculations?

I was told that for 1 property <=> 1 property mapping I should use MapFrom, but when the destination property is somehow computed or changed, then I should use ResolveUsing. However, when I use this mapping, it still works:

.ForMember(item => item.Validity, record => record.MapFrom(r => new DateInterval(r.Start, r.End)))

In fact, I can’t even find the difference in how the two functions work.

Is there any real difference?

+5
source share
1 answer

The MapFrom method will do things like null checks, etc., which can be done by examining the expression tree. ResolveUsing - you really do not get anything "superfluous". The idea was MapFrom was from a different property, and ResolveUsing is all you want.

+3
source

All Articles