假设我有两个模型类:
public class People {
public string FirstName {get;set;}
public string LastName {get;set;}
}
也有一个类电话:
public class Phone {
public string Number {get;set;}
}
我想转换成这样的 PeoplePhone:
public class PeoplePhoneDto {
public string FirstName {get;set;}
public string LastName {get;set;}
public string PhoneNumber {get;set;}
}
比方说,在我的控制器里,我有:
var people = repository.GetPeople(1);
var phone = repository.GetPhone(4);
// normally, without automapper I would made
return new PeoplePhoneDto(people, phone) ;
这可能吗?