我知道如何获取Dynamic Linq来投影子(非集合)对象,例如
"new(new(CustomerStat.ID) as CustomerStat)", where CustomerStat is a non-collection object.
我想对集合执行类似的操作,例如"new(LocationId, new(Employees.Select(FirstName)) as Employees)"
,这将返回一个预计的位置列表,以及雇员的子列表,其中仅包含他们的第一个名称。
换句话说,我想要以下的DynamicLinq版本:
var locations = (new CompanyContext().Locations.
Select(l => new {l.ID, Emps = l.Employees.Select(e=>e.FirstName)}));
谢谢!