Reputation: 6056
How to use the let statement in outer join of LINQ to SQL?
Something like below,
from a in tableA
from b in tableB.where(o => a.Key == o.Key).DefaultIfEmpty() //outer join
let x = b.objectBB
where b != null && x != null && x.FilterCode == "X"
So,
- Does the above query is fine?
- Will the 'let' fail if 'b' is null ?
- what will happen with the where clause on 'x'? Does this filter work fine?
Any better way to achieve this also much welcome.!
Upvotes: 1
Views: 974
Reputation: 3755
Seems to me that if you want both sides to be not null, don't you just want an inner join?
from a in tableA
join b in tableB on a.Key equals o.Key
where b.FilterCode == "X"
Upvotes: 1