문제

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 ?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top