0

I need to map the Fields of My Class to RegisterNewPeopleCommand, but in the third field (passed parameter) I must pass a List of Phones (List ) that is inside the PeopleViewModel class (PeopleViewModel.PeopleListPhones). I need to convert from List to List . How do I do that? Should I use any loopback or other feature?

CreateMap<PeopleViewModel, RegisterNewPeopleCommand>()
    .ConstructUsing(p => new RegisterNewPeopleCommand(p.Id, p.Name, p.PeopleListPhones //I need to convert this List <Phone ViewModel> property to List <Phone Model>)

));

public abstract class RegisterNewPeopleCommand(int id, string name, List<PhoneModel> phonesModel)
{
    Id = id;
    Name = name;
    PhonesNumber = phonesModel;
}

public class PhoneModel()
{
    public int PhoneId
    public string Number
}

public class Phone()
{
    public int PhoneId
    public string Number
}
Master JR
  • 231
  • 2
  • 11

0 Answers0