0

I want to select all records from table 1 and if there any match between table 1 and table 2 then I have to exclude that records.

Note: The requirement is I have to use left outer join for that..

For example,

table 1    table 2
1           1
2           2
3

Output should be 3

I have written query in SQL but I want this in SQL LINQ like from a in dbContext.Table1....

select t1.*
from table1 t1
left outer join table2 t2 on t1.ID = t2.ID and t1.Code = t2.Code 
where s.ID is null

How to solve this?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Rushi
  • 1
  • 3

1 Answers1

0
var result = (from primer in one
                     join  primer2 in two on primer.id equals primer2.id into gj
                     where gj.Count()==0
                     select new
                     {
                         primer.id
                     }).ToList();

Where ONE - it is first table, TWO - it is second table. Instead of

...select new
                     {
                         primer.id
                     }...

You can use

...
select primer
...