How to use "Not Exists" in LINQ?

3

I'm trying to translate the query below into LINQ, but without success, can anyone help me?

SELECT * FROM PESSOAL A 
WHERE NOT EXISTS (
    SELECT Chapa FROM PRODUCAO B 
    WHERE B.Chapa = A.Chapa AND B.Data='2014-09-02') 
AND A.Codsubord='CB02010100';
    
asked by anonymous 10.09.2014 / 16:22

1 answer

2

Try:

db.Pessoal.where(a => !db.Producao.Any(b => b.Chapa == a.Chapa && b.Data == new DateTime(2014, 09, 02)) && a.Codsubord== "CB02010100");

So, I'm going to get all data from the Pessoa ( SELECT * FROM PESSOAL ) table, where the Producao data you want is not available. Stop such use !db.Producao.Any(...) to make NOT EXISTS

    
10.09.2014 / 16:31