1

I try to map a list of objects with ValueInjecter using a LINQ query like this :

var thingsCollection = rep.Things.Select(x => new ThingDTO().InjectFrom(x) as ThingDTO)
                                     .OrderByDescending(x => x.StartDate).ToList();

The problem is that the Thing and the ThingDTO objects contain other objets :

public class ThingDTO
{
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public MaterialDTO Material{ get; set; }
}

What kind of injection method should I use to get the sub object map ? Or do I have to do a foreach instead of the LINQ query ?

Patrice Cote
  • 3,572
  • 12
  • 43
  • 72
  • you would have to do it manually for each new mapped object you need to instantiate the collection manually and add the new mapped elements – Omu Jul 25 '13 at 12:51
  • That's what I ended up doing. Works fine. If you want to post your comment as an answer I will accept it. – Patrice Cote Jul 25 '13 at 19:54

1 Answers1

1

you would have to do it manually for each new mapped object you need to instantiate the collection manually and add the new mapped elements

Omu
  • 69,856
  • 92
  • 277
  • 407