如何在linq中写入where子句和left join? [英] how to write where in clause and left join in linq ?
本文介绍了如何在linq中写入where子句和left join?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个sql querry有where子句以及left join如何将它转换为linq?
I've a sql querry having where in clause as well as left join how can i convert it into linq ??
select a.id,name,displayname,favtcol from
(select * from reportdetails where id in
(select reportid from ReportAuthorization where role='user' or loginid = 'a') ) as a left join auditreport as b on a.id= b.reportid
推荐答案
var reportsByAuth =
from d in
(from c in rbaDC.ReportDetails
from d in rbaDC.ReportAuthorizations
where c.id == (d.reportid) && (d.role == "admin" || d.loginid == "a")
select new { c.id, c.displayname, c.name })
join ef in rbaDC.auditreports
on d.id equals ef.reportid
select new { d.id,d.displayname,d.name,ef.favtcol };
有人可以告诉我这个答案是否有效?
Can anybody please tell me if this answer is valid?
这篇关于如何在linq中写入where子句和left join?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文