Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How might I convert this SQL code to LINQ?

Tags:

sql

linq

How might I convert this SQL code to LINQ?

SELECT * FROM tbl1  
  WHERE NOT EXISTS (SELECT NULL AS Expr1
            FROM tbl2 AS tbl2_1
            WHERE (T = 'literal') AND tbl1.Id = someId)

This is what I have, but it doesn't work:

from a in Tbl1 
let b = from b in Tbl2 select b.someId   
let c = from c in Tbl2 select c.T 
where (!c.Contains("literal") & !(b.Contains(a.Id)))
select a
like image 940
user1457485 Avatar asked Dec 29 '25 00:12

user1457485


1 Answers

This should do the trick:

from t1 in Tbl1
where !(from t2 in Tbl2
    where t2.T == "literal"
    select t2.someId)
       .Contains(t1.Id)
select t1
like image 123
arcain Avatar answered Dec 31 '25 15:12

arcain