开发者

How to map single object of type x to array of object of type y using automapper

开发者 https://www.devze.com 2022-12-19 04:59 出处:网络
Mapper.CreateMap<A, B>() .ForMember(dest => des开发者_StackOverflow中文版t.defs, opt => opt.MapFrom(origin => origin.abc));
Mapper.CreateMap<A, B>()
      .ForMember(dest => des开发者_StackOverflow中文版t.defs, opt => opt.MapFrom(origin => origin.abc));

where defs is array of Def (Def[])

how to map?


Mapper.CreateMap<A, B>()
      .ForMember(dest => dest.defs, opt => opt.MapFrom(origin => new[]{ origin.abc }));

destination property is array of Def and so the source requries array of something, that's how automapper understands...

this works!!!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号