How to Use "Not Exists" in LINQ?

Asked

Viewed 1,838 times

4

I am trying to translate the query below, in LINQ, but without success, someone can 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';

1 answer

4


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 getting all the data from the table Pessoa (SELECT * FROM PESSOAL), where the data of the Producao that you intend to. Stop such use the !db.Producao.Any(...) to do the NOT EXISTS

  • I have difficulty with lambda expressions and tried to try but the visual returned errors

  • and what mistake was?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.