我尝试使用如下 LINQ 查询使用 ValueInjecter 映射对象列表:
var thingsCollection = rep.Things.Select(x => new ThingDTO().InjectFrom(x) as ThingDTO)
.OrderByDescending(x => x.StartDate).ToList();
问题是 Thing 和 ThingDTO 对象包含其他对象:
public class ThingDTO
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public MaterialDTO Material{ get; set; }
}
我应该使用什么样的注入方法来获取子对象映射?还是我必须做一个 foreach 而不是 LINQ 查询?