how can I map Person to Company:
public class Person
{
public Guid Id { get; set;}
public string Name { get; set;}
public string Country { get; set;}
public string PhoneNumber { get; set;}
}
public class Company
{
public List<Member> Members { get; set; }
public string Name { get; set;}
}
public class Member
{
public Guid Id { get; set;}
public string FullName { get; set; }
}
I tried to do it with auto mapper but I couldn’t success .
2
Answers
I assume when mapping
Person
toMember
, you want thePerson.Name
andMember.FullName
to be the mapped.So for that I would do this.
As for mapping
Person
toCompany
, I really don’t understand why you would map these two if you already havePerson
andMember
mapped.Create a AutomapperProfile Helper class and add all the mapping in there .