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;

4 Comments»

  1. Thanks for this tip! This was exactly what I was looking for :)

    Comment by Jeroen Landheer — April 3, 2008@ 7:13 pm

  2. < blockquote >< a href=”http://pillspot.org/”>Pillspot.org. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. High quality pills. Buy drugs online< /a >…

    Buy:Prevacid.Prednisolone.Retin-A.100% Pure Okinawan Coral Calcium.Mega Hoodia.Valtrex.Zyban.Arimidex.Human Growth Hormone.Actos.Zovirax.Nexium.Lumigan.Petcam (Metacam) Oral Suspension.Accutane.Synthroid….

    Trackbackby LAWRENCE — July 1, 2010@ 4:27 pm

  3. audio http://cmp38bkaqg.03GMCPARTS.US/tag/Cable+PC+audio/ : PC…

    Cable…

    Trackbackby Cable — August 30, 2010@ 5:18 am

  4. 2009 http://zgu.oll.ii99.co : 2009…

    2009…

    Trackbackby 2009 — September 15, 2010@ 4:43 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Spam protection by WP Captcha-Free

Powered by Mucitsoft