T-Sql ‘exists’ command in Linq to Sql
Filed under: T-Sql to Linq Upgrade — admin @ 4:38 pm
T-Sql exists Usage:
select *
from Customers c
where exists(select *
from Orders
where ShipCountry = ‘Germany’
and CustomerId = c.CustomerId)
Linq contains usage instead of exists:
DataClassesDataContext db = new DataClassesDataContext();
var Cust = from c in db.Customers
where (from o in db.Orders
where o.ShipCountry == “Germany”
select o.CustomerID).Contains(c.CustomerID)
select c;

Thanks for this tip! This was exactly what I was looking for
Comment by Jeroen Landheer — April 3, 2008@ 7:13 pm