AutoMapper convert from multiple sources
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Let's say I have two model classes: public class People { public string FirstName {get;set;} public string LastName {get;set;} } Also have a class Phone: public class Phone { public string Number {get;set;} } And I want to convert to a PeoplePhoneDto like this: public class PeoplePhoneDto { public string FirstName {get;set;} public string LastName {get;set;} public string PhoneNumber {get;set;} } Let's say in my controller I have: var people = repository.GetPeople(1); var phone = repository.GetPhone(4); // normally, without automapper I