I have a domain and entity class the looks like this:
public class DomainUser
{
public string Username {get;set;}
public IList<string> PhoneNumbers {get;set;}
}
public class EntityUser
{
public string Name {get;set;}
public IList<Phone> PhoneNumbers {get;set;}
}
public class Phone
{
public int Id {get;set;}
public string PhoneNumber {get;set;}
}
I'm trying to map the DomainUser to EntityUser with Automapper. But I don't know how to map from IList<string> to IList<Phone> and fill the PhoneNumer property.
My CreateMap looks like this:
Config.CreateMap<DomainUser, EntityUser>()
.ForMember(dest => dest.Username, opts => opts.MapFrom(src => src.Username)
.ForMember(entity => entity.PhoneNumbers.Select(x => x.PhoneNumber), opts => opts.MapFrom(domain => domain.PhoneNumbers) // This doesn't work, but hopefully shows what I'm trying to achieve
How can I solve this issue with AutoMapper?