How do I get AutoMapper to map this?

心不动则不痛 提交于 2019-12-03 21:44:21

AutoMapper does that out of-the-box if you provide a configuration for the Enterprise and User type.

Configuration looks like this:

Mapper.CreateMap<Account, AccountDto>();
Mapper.CreateMap<Enterprise, EnterpriseDto>();
Mapper.CreateMap<User, UserDto>();

This shows how to how collections get mapped: http://automapper.codeplex.com/wikipage?title=Lists%20and%20Arrays&referringTitle=Home

You need to create a mapping for each pair of types you would like mapped.

Mapper.CreateMap<Account, AccountDto>();
Mapper.CreateMap<Enterprise, EnterpriseDto>();
Mapper.CreateMap<User, UserDto>();

Order is not important.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!