Are there any Value Injecter map collection properties?

I am trying to map a collection of EntityFramework objects to 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 list of reports is not displayed. What am I doing wrong?

  IList<ChannelListViewModel> viewModelList = channelList.Select(x => new ChannelListViewModel().InjectFrom(x)).Cast<ChannelListViewModel>().ToList(); 
+4
source share
2 answers

No, not by default, you should use a custom injector. This is why I switched back to automapper after overturning the valueinjecter. How to match lists with ValueInjector

+3
source

There is a self-similar simulation that does this:

http://valueinjecter.codeplex.com/releases/view/60311#DownloadId=318259

you can download it and see how collections are collected automatically

here's an article: http://valueinjecter.codeplex.com/wikipage?title=Automapper%20Simulation&referringTitle=Home

you can see module tests there

+1
source

Source: https://habr.com/ru/post/1401473/


All Articles