我有以下linq查询可以正常工作,但我想从context.Emps中将一列(CompanyId)与context.BillingProfiles的结果一起拉入结果。我如何修改下面的select(select prof)以包含所述列?
{
"error": "some error",
"result": null
}
由于
答案 0 :(得分:1)
投射一个包含这些内容的匿名对象:
var query = from prof in context.BillingProfiles
join emp in context.Emps on prof.ID equals emp.ID
join grp in context.BillingGroups on prof.GroupID equals grp.GroupID
where prof.EndDate == null && prof.ID == id && grp.System == "sysGrp"
select new { prof, emp.CompanyId, grp };