I'm using AutoMapper 9 and I want to mapping my nested table. In older version of AutoMapper I've used "CreateMap" like this:
CreateMap<Table, ViewModel>().AfterMap((s, d) => Mapper.Map(s.Table2, d)).ReverseMap();
I've found this example below but this working for only one element of table.
CreateMap<Table, ViewModel>().ForMember(d=>d.Items,o=>o.MapFrom(s=>s.Table2.Items));
but in new version (Mapper.Map) not working because AutoMapper using dependency injection. How to use nested mapping in new version in simply way? I'm not concealing that I'd like using AutoMapper without dependency injection.
Finally I've found solution. It may be useful to someone:
So if you have nested table and using AutoMapper try this below.
CreateMap<Table, ViewModel>().IncludeMembers(m=>m.NestedTable);