2011-10-27 10 views
5

in T-SQL, abbiamoIl 'in' predicato in Entity Framework

where empid in (1, 3, 5) 

Ora supponiamo che ho un List<int>, come faccio a scrivere una query LINQ to Entities, vale a dire un predicato per Where() per ottenere la equivalente della query SQL precedente? O questo non è supportato affatto?

Grazie,

+0

Questo potrebbe aiutare a uscire http://stackoverflow.com/questions/959752/where-in-clause-in-linq –

risposta

5

provare questo:

var Products = from product in dbctx.Products 
      where itemQuery.Contains(product.ProductID) 
      select product; 
+0

fresco, 'Contiene 'sarà tradotto ed è ciò che voglio. Grazie. – Dodd

Problemi correlati