I am using automapper to map source and destination objects. While I map them I get the below error.
Expression must resolve to top-level member. Par
The correct answer given by allrameest on this question should help: AutoMapper - Deep level mapping
This is what you need:
Mapper.CreateMap()
.ForMember(dest => dest.OutputData, opt => opt.MapFrom(i => i));
Mapper.CreateMap()
.ForMember(dest => dest.Cars, opt => opt.MapFrom(i => i.Cars));
When using the mapper, use:
var destinationObj = Mapper.Map(sourceObj)
where destinationObj is an instance of Destination and sourceObj is an instance of Source.
NOTE: You should try to move away from using Mapper.CreateMap at this point, it is obsolete and will be unsupported soon.