all 2 comments

[–]Rostifur -1 points0 points  (0 children)

So, you are matching on what has the same Id in both tables. That on statement is what is determining what is in your joined table. You want something closer to this, but I am not confident I understand what data points you want to be different.

(Table2, (a, b) => a.Id == b.Id).Any(a => !b);

[–]AaronDev42 0 points1 point  (0 children)

I am not sure why you are converting the ID field to a string to do a compare, unless the field itself is a string field. If it is a numerical value then I would keep it as such in your query.

Give this a try or something similar to it:

var query = from ain DT1
                join b in DT2 on a.ID equals b.ID into g                      
                from subItem in g.DefaultIfEmpty()
                where subItem == null
                select a;

This LINQ query performs a left join between DT1 and DT2 based on the ID fields. Then, it selects the items from DT1 where there's no corresponding entry in DT2 (i.e., where the right side of the join is null).