I have two classes below:
public class Module
{
public int Id { get; set; }
public string Name { get; set; }
public string ImageName { get; set; }
public virtual ICollection<Page> Pages { get; set; }
}
public class ModuleUI
{
public int Id { get; set; }
public string Text { get; set; }
public string ImagePath { get; set; }
public List<PageUI> PageUIs { get; set; }
}
The mapping must be like this:
Id -> Id
Name -> Text
ImageName -> ImagePath
Pages -> PageUIs
How can I do this using Automapper?
new ModuleUI {Id = module.Id, ImagePath = module.ImageName, PageUIs = new List<PageUI>(module.Pages.Cast<PageUI>())};
– Gaylordgaylussac