I have a viewmodel containing IList of viewmodels:
public class MyCustomViewModel
{
public IList<ItemViewModel> Items { set; get; }
public IList<PersonViewModel> Persons { set; get; }
public MyCustomViewModel()
{
}
}
In my controller's Index action method I'm not able to figure out how to correctly map this kind of nested viewmodels.
Normaly I would do something like:
IList<Item> items= db.Items.ToList();
var viewModel = Mapper.Map<IList<ItemViewModel>>(item);
How would that work with a viewmodel containing several other viewmodels? I've been trying to create new instances of each viewmodel separately but I fail to see how to map them all to my custom viewmodels.
I can't map viewmodels to other viewmodels, can I?