0
我有以下linq查询可以正常工作,但我想从context.Emps中将一列(CompanyId)与来自上下文的结果一起拖放到结果中.BillingProfiles。我如何修改下面的select(select prof)以包含所述列?如何从LINQ查询中的第二个表中拉出一列加入
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) && (grp.System == "sysGrp") && (prof.ID == id)
select prof).Distinct()
.Select(x => new OpId()
{
id = x.ID,
GroupId = x.GroupID,
OpId = x.OpID,
StartDate = x.StartDate,
EndDate = x.EndDate,
AddedOn = x.AddedOn,
AddedBy = x.AddedBy,
RemovedOn = x.RemovedOn,
RemovedBy = x.RemovedBy,
Prodid = x.ProdID,
});
感谢
要多一点背景添加到吉拉德的答案,你会写你的最终选择后的匿名对象是这样的: ()); select new {prof,emp.CompanyID,grp})。Distinct()。Select(x => new OpId(){//使用prof,grp等 }); – Peter