I have two tables in an XML Dataset. T1, T2. Each of the tables has a ID column.
T1 has a list of Customers T2 has a list of Orders
I want to build a LINQ query that returns only the ID of the customers that do not have orders. In other words customer ID's that do not exist in the T2 table.
Oh yea, I'm using C#
Thanks!
This requires an outer join and a check on null.
var result = from c in Customers
join d in Details on d.CustomerID equals c.ID into g
where !g.Any()
select c;
I think this will work (please adapt to your DataSets):
var query = from c in T1
where !(from o in T2 select o.CustomerID)
.Contains(c.CustomerID)
select c;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With