Im trying to figure out to how to map a list to an object containing an identical list property
I have a view model that looks like this:
public class GenerateCodeVM
{
public List<AnimalVM> Animal { get; set; }
public List<RegionVM> Region { get; set; }
}
public class AnimalVM
{
public int? AnimalID { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public DateTime? LastUpdated { get; set; }
}
public class RegionVM
{
public int? RegionID { get; set; }
public string RegionName { get; set; }
public string Code { get; set; }
}
In the controller I have:
GenerateCodeVM generateCodeVM = new GenerateCodeVM();
AnimalRepository animalRepository = new AnimalRepository();
List<Animal> animal = animalRepository.GetAll().ToList();
RegionRepository regionRepository = new RegionRepository();
List<Region> region = regionRepository.GetAll().ToList();
generateCodeVM = Mapper.Map<List<Region>, GenerateCodeVM> (region);
generateCodeVM = Mapper.Map<List<Animal>, GenerateCodeVM>(animal);
How do I configure the mappings in automapper?