30 April 2012

T-SQL And Linq To Sql Reference: IN

1. T-SQL
 select *   
 from Orders o  
 where ProductID IN (3, 4, 5)  
2. Linq
Code:
List<int> filter = new List<int>();  
filter.add(3);  
filter.add(4);  
filter.add(5);  
var orders = from o in dc.Orders    
          where filter.Contains(o.ProductID)  
          select o;