var surgeonList = (
from item in context.T1_STM_Surgeon
.Include("T1_STM_SurgeonTitle")
.Include("OTER")
where item.ID == surgeonId
join reptable in context.OSLP
on item.Rep equals reptable.SlpCode
select new
{
ID = item.ID,
First = item.First,
Last = item.Last,
Rep = reptable.SlpName,
Reg = item.OTER.descript,
PrimClinic = item.T1_STM_ClinicalCenter.Name,
Titles = item.T1_STM_SurgeonTitle,
Phone = item.Phone,
Email = item.Email,
Address1 = item.Address1,
Address2 = item.Address2,
City = item.City,
State = item.State,
Zip = item.Zip,
Comments = item.Comments,
Active = item.Active,
DateEntered = item.DateEntered
}).ToList();
提前致谢!!
答案 0 :(得分:0)
语法如下,如果您在翻译代码时遇到问题,请告诉我。 通用外连接(组连接):
var query = 从左边的l
join r in right
on l.ID
equals l.right.ID into groupedJoin
select new
{
ID= l.ID,
OuterJoined= groupedJoin.Select(r=> right)
};
即使权利不存在,你的结果仍然是左边的一切。
显然我无法保证它会编译,但它看起来像这样:
var surgeonList =(
from item in context.T1_STM_Surgeon
.Include("T1_STM_SurgeonTitle")
.Include("OTER")
where item.ID == surgeonId
join reptable in context.OSLP
on item.Rep equals reptable.SlpCode into groupedJoin
select new
{
ID = item.ID,
First = item.First,
Last = item.Last,
Rep = reptable.SlpName,
Reg = item.OTER.descript,
PrimClinic = item.T1_STM_ClinicalCenter.Name,
Titles = item.T1_STM_SurgeonTitle,
Phone = item.Phone,
Email = item.Email,
Address1 = item.Address1,
Address2 = item.Address2,
City = item.City,
State = item.State,
Zip = item.Zip,
Comments = item.Comments,
Active = item.Active,
DateEntered = item.DateEntered
OSLP = groupedJoin.Select(x=>WHATEVERYOUNEED)
}).ToList();
你只需要用选择的东西或简单的替换groupsJoin.Select(x => WHATEVERYOUNEED).ToList