如何联合linq这个表 [英] How to union to linq this tables
本文介绍了如何联合linq这个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已加入多个表格以及如何只联合两张桌子
我尝试过的事情:
i have already join multiple tables and how to union just two tables only
What I have tried:
var reff = (from ep in db.Tbl_YouthBasicInfo
join e in db.POCPremiums on ep.YouthID equals e.YouthID
join p in db.WrapLogic_SCCOC_PotentialCrises on e.POCId equals p.POCId
join v in db.WrapLogic_SCCOC_PotentialCrises_ActionStep on p.PotentialCrisesID equals v.PotentialCrisesId
join b in db.WrapLogic_SCCOC_ActionStep_BillableService on v.ActionStepID equals b.ActionStepId
orderby ep.YouthID
where b.ProviderId == userid
select new
{
ep.FirstName,
ep.MiddleInital,
ep.LastName,
b.RequisitionNo,
b.ServiceStartDate,
b.ServiceEndDate,
b.TotalServiceUnits,
b.TotalCost
});
推荐答案
如果你想加入只是2仅限表格,使用单个加入
+选择新的
:
If you want to join "just 2 tables only", use singlejoin
+select new
:
var reff = (from a in tableA
join b in tableB on a.Id = b.ForeignId
select new
{
Col1 = a.Id,
Col2 = a.Name,
Col3 = b.Address,
Col4 = b.Zip
})
.ToList();
这篇关于如何联合linq这个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文