Automapper expression must resolve to top-level member

前端 未结 5 974
感情败类
感情败类 2020-12-06 09:29

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

5条回答
  •  [愿得一人]
    2020-12-06 10:03

    You can do it that way:

    // First: create mapping for the subtypes
    Mapper.CreateMap();
    
    // Then: create the main mapping
    Mapper.CreateMap().
        // chose the destination-property and map the source itself
        ForMember(dest => dest.Output, x => x.MapFrom(src => src)); 
    

    That's my way to do that ;-)

提交回复
热议问题