有人可以告诉我如何在SQL
中撰写以下linq
查询:
SELECT approvaldate, issubmitted, companyemail, *
FROM registrations r
WHERE (r.issubmitted = 'true')
AND (r.approvaldate IS NULL)
AND (companyemail LIKE '%gmail%'
OR companyid IN (SELECT companyid FROM companies
WHERE companyname LIKE '%gmail%')
)
由于
答案 0 :(得分:0)
请尝试使用以下代码段。 (如果有任何疑虑,请告诉我,因为我没有测试过查询)
var query = (from r in registrations
Where r.issubmitted = true
&& r.approvaldate.HasValue == false
&& (
r.companyemail.IndexOf("gmail") >= 0
||
companies.Any(c => c.companyid == r.companyid && c.companyname.IndexOf("gmail") >= 0)
)
select r).ToList();
请查看以下链接以供参考
http://csharp-guide.blogspot.in/2012/05/linq-to-sql-sub-queries.html
答案 1 :(得分:0)
var query = registrations.Where(x=>
x.issubmitted &&
x.approvaldate == null &&
(
companyemail.Contains("gmail") ||
companies.Any(y => y.companyid == x.companyid &&
y.companyname.Contains("gmail"))
));