The MapFrom method of AutoMapper has two overloads:
.MapFrom(Expression<Func<object, object>>
and
.MapFrom<TMember>(string)
The first overload can be used like this:
.ForMember(dest => dest.Date, opt => opt.MapFrom(order => order.Customer.DateOfBirth))
I tried the second overload like this:
.ForMember(dest => dest.Date, opt => opt.MapFrom<DateTime>("Order.Customer.DateOfBirth"))
But it does not work when using a property of an association. Who nows how this second overload can be used when using flattening?
I ask this because I look for a way to do the mapping dynamically; for example:
.ForMember(dest => dest.Date, opt => opt.MapFrom<DateTime>(givenPropertyString))
Thanks in advance.