我知道如何让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)}));
谢谢!