0
unflatten我有一個這樣的例子: Automapper由前綴
class Fields
{
string ContactOneName{get;set;}
string ContactOnePhone{get;set;}
string ContactOneSpouseName{get;set;}
string ContactOneSpousePhone{get;set;}
}
而且我想映射到這樣一個模型:
class Contacts
{
Contact ContactOne {get;set;}
Contact ContactOneSpouse {get;set;}
}
class Contact
{
string Name {get;set;}
string Phone {get;set;}
}
有許多領域和我不不想爲每個字段寫一個映射。 這可能嗎? 如果是這樣怎麼樣?
注意:這個問題幾乎是AutoMapper unflattening complex objects of same type的重複,但我想要一個解決方案而不是手動映射所有東西,因爲在這種情況下,它不值得使用automapper。