gpt4 book ai didi

C# Linq 多级连接表

转载 作者:太空宇宙 更新时间:2023-11-03 13:53:08 27 4
gpt4 key购买 nike

我正在尝试查询 3 级表 ef_staff 表 3 次,以获取每行的 3 个差异人员对象。如何在 LINQ 中翻译这个?

SELECT a.a_appraisalid, a.a_year, c.s_staffName, c2.s_staffName, c3.s_staffName
FROM ef_appraisal a, idp_application b, ef_staff c, ef_staff c2, ef_staff c3
WHERE a.a_appraisalid = b.a_appraisalid AND
a.a_staffid = c.s_staffid AND
a.a_appraisedby = c2.s_staffid AND
a.a_reviewedby = c3.s_staffid

我尝试了很多方法,但在第 2 次和第 3 次加入 Staff 时仍然出现“Type Inference Failed”错误。我在这里缺少什么?

from application in applications

join appraisal in pmsEntities.ef_appraisal on application.a_appraisalid equals appraisal.a_appraisalid

join staff in pmsEntities.ef_staff on appraisal.a_staffid equals staff.s_staffid

join appraiser in pmsEntities.ef_staff on staff.s_appraisedby equals appraiser.s_staffid into ap

from appraiser in ap.DefaultIfEmpty()

join reviewer in pmsEntities.ef_staff on staff.s_reviewedby equals reviewer.s_staffid into rv

from reviewer in rv.DefaultIfEmpty()

join company in pmsEntities.ef_company on appraisal.a_companyid equals company.c_companyid into jc

from company in jc.DefaultIfEmpty()

select appraisal, staff.staffName, appraiser.staffName, reviewer.staffName, company.compName

最佳答案

我改正了错误。员工对象的第一级加入应链接到员工对象的第二级,如下所示:

加入 staff in pmsEntities.ef_staff on appraisal.a_staffid equals staff.s_staffid into staffj

                    from staff1 in staffj

join appraiser in pmsEntities.ef_staff on staff1.s_appraisedby equals appraiser.s_icno into staff2

`

希望对你有帮助

关于C# Linq 多级连接表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13157436/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com