I have an example like this :
class Fields
{
string ContactOneName{get;set;}
string ContactOnePhone{get;set;}
string ContactOneSpouseName{get;set;}
string ContactOneSpousePhone{get;set;}
}
And I would like to map to a model like this:
class Contacts
{
Contact ContactOne {get;set;}
Contact ContactOneSpouse {get;set;}
}
class Contact
{
string Name {get;set;}
string Phone {get;set;}
}
There are lots of fields and I don't want to write a mapping for each field. Is this possible? If so how?
NB: This question is almost a duplicate of AutoMapper unflattening complex objects of same type but I want a solution NOT manually mapping everything, because in that case it is not worth using automapper.