假设我有两个模型类:
public class People {
public string FirstName {get;set;}
public string LastName {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
还有一类电话:
public class Phone {
public string Number {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我想转换为PeoplePhoneDto,如下所示:
public class PeoplePhoneDto {
public string FirstName {get;set;}
public string LastName {get;set;}
public string PhoneNumber {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
让我们在我的控制器中说:
var people = repository.GetPeople(1);
var phone = repository.GetPhone(4);
// normally, without automapper I would made
return new PeoplePhoneDto(people, phone) ;
Run Code Online (Sandbox Code Playgroud)
我似乎找不到这个场景的任何例子.这可能吗 ?
注意:示例不是真实的,仅针对此问题.