I have Source Object which will be like below,
Class Employee
{
int EmpID { get; set; }
string EmpName { get; set; }
List<AddressRelation> AddressRelations { get; set; }
}
Class AddressRelation
{
int AddressRelationId { get; set; }
int AddressTypeId { get; set; }
int AddressId { get; set; }
}
Class Address
{
int AddressId { get; set; }
string AddressLine1 { get; set; }
string AddressLine2 { get; set; }
string City { get; set; }
string State { get; set; }
string Zip { get; set; }
}
**Destination Object**
Class EmployeeDTO
{
int EmpID { get; set; }
string EmpName { get; set; }
List<AddressDTO> Addresses { get; set; }
}
Class AddressDTO
{
int AddressId { get; set; }
string AddressLine1 { get; set; }
string AddressLine2 { get; set; }
string City { get; set; }
string State { get; set; }
string Zip { get; set; }
}
Now, the Source Object has AddressRelation collection, inside that list of Address will be there.. means there will be 0-n AddressRelation for an employee and inside each AddressRelation there will be 0-n Address.
Now, I want to map only the Addresses from Source Object and Assign it to Destination Object's Address collection using Automapper. means iterate each AddressRelation, take the Addresses and assign to Destination Object's Address Collection. how to do this using AutoMapper ?
Thanks in advance, Prakash.