Search code examples
asp.net-mvc-3valueinjecter

Does Value Injecter map collection properties?


I'm trying to map a collection of EntityFramework objects with a collection of view models.

 public class Channel
{
    public Guid Id { get; set; }

    public string Name { get; set; }

    public IEnumerable<Report> Reports { get; set; }
}

public class ChannelListViewModel
{
    public Guid Id { get; set; }

    public string Name { get; set; }

    public IEnumerable<Report> Reports { get; set; }
}

Using the code below the Reports list is not being mapped. What am I doing wrong?

 IList<ChannelListViewModel> viewModelList = channelList.Select(x => new ChannelListViewModel().InjectFrom(x)).Cast<ChannelListViewModel>().ToList();

Solution

  • No, not by default, you have to use a custom injecter. This is why I switched back to automapper after trying out valueinjecter. How to map lists with ValueInjector