2009-01-28

LINQ Where in and Not in

在LINQ內如何如用in及not in呢
正常SQL語法

Select * From Customers Where City IN ('UK', 'TW')

在LINQ呢?

Dim query = From c In db.Customers Where (New String() {"UK", "TW"}).Contains(c.City) Select c

那NOT IN呢?

Dim query = From c In db.Customers Where Not (New String() {"UK", "TW"}).Contains(c.City) Select c

0 comments: