I have been trying to get this going, but when i debug my test, the objects return null. I want to do complex object to object mapping but i cant get it to work.
Instead of:
cfg.CreateMap<Payments, Customer.Payments>()
.ForMember(to => to.SomeName, opts => opts.MapFrom(from => from.SomeName))
.ForMember(to => to.SomeDate, opts => opts.MapFrom(from => from.SomeDate));
We want to do:
cfg.CreateMap<Payments, Customer.Payments>();
I'd definitely checkout their Wiki if you haven't already.
Based on your comment above, it looks like you're confused about the signature of mapper.map
.
This is what you could do: var dest = mapper.Map<Dest>(new Source());
Checkout this simple fiddle for a working example based on the code you posted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.