我有一个automapper轮廓,并用高级开发人员工作时,他给了我一个指针做一个IEnumerable一个创建地图,我得到了一些编码,但现在我卡住了。CreateMap为IEnumerable的
我想这
CreateMap<IEnumerable<BusinessInfo>, IEnumerable<AdminViewModel.Account>>().ForAllMembers(i => i.Ignore());
CreateMap<IEnumerable<BusinessInfo>, IEnumerable<AdminViewModel.Account>>()
.ForMember(i => i.COMPANY, opt => opt.MapFrom(p => p.Company))
,但公司有差错,因为它不包含公司的定义...... 我想我失去了一些东西,但我不能确定它是什么。
你会通常只定义地图的个别型号,而不是[模型集合(https://开头github上。 com/AutoMapper/AutoMapper/wiki/Lists-and-arrays)'CreateMap()'。然后AutoMapper将能够映射集合。看到你想要映射的类将会很有帮助。 –
Jasen