Converting "is null" into a linq to sql statement
Posted
by Darryl Braaten
on Stack Overflow
See other posts from Stack Overflow
or by Darryl Braaten
Published on 2009-02-02T06:03:33Z
Indexed on
2010/04/09
2:13 UTC
Read the original article
Hit count: 383
linq-to-sql
I am having trouble replicating the following sql as a LINQ statement
select TableA.* from TableA left outer join TableAinTableB on TableA.Id = TableAId where TableBId is null
The following returns no lines
from TableA in db.TableA join AinB in db.TableAinTableB on TableA.Id equals TableAId where AinB.TableBId == null select TableA
Also tried and a few other things that didn't work.
from TableA in db.TableA join AinB in db.TableAinTableB on TableA.Id equals TableAId where AinB == null select TableA
TableAinTableB is a many to many table. The query I want will pull all the records from TableA that have no records in the middle table. My sql does what I want but I have no idea how to convert it to LINQ to SQL.
I ended up working around it by just doing a db.ExecuteQuery("working sql"); But I would like to know if the query is possible in LINQ and how to write it, or a pointer to a document that covers this scenario. My searching did not uncover anything I found useful.
© Stack Overflow or respective owner