In order to use SQL IN condition in LINQ, you need break down to two steps:<br><br>
1. Create condition set <br>
2. Apply condition set in result query by <b>Queryable.Contains</b> or <b>Enumerable.Contains</b> method.<br><br>
For example,<br><br>
SQL query<br>
SELECT * FROM Products WHERE ProductID IN (SELECT ProductID FROM [Order_Details] WHERE OrderID = order_ID)<br><br>
By LINQ query<br><br>
NorthWindDB db = new NorthWindDB();<br>
// Condition set<br>
var itemQuery = from ProductItems in db.Order_Details<br>
where ProductItems.OrderID == order_ID<br>
select ProductItems.ProductID;<br><br>
// Result query<br><br>
var myProducts = from p in db.Products<br>
where itemQuery.Contains(p.ProductID)<br>
select p; <br>
1. Create condition set <br>
2. Apply condition set in result query by <b>Queryable.Contains</b> or <b>Enumerable.Contains</b> method.<br><br>
For example,<br><br>
SQL query<br>
SELECT * FROM Products WHERE ProductID IN (SELECT ProductID FROM [Order_Details] WHERE OrderID = order_ID)<br><br>
By LINQ query<br><br>
NorthWindDB db = new NorthWindDB();<br>
// Condition set<br>
var itemQuery = from ProductItems in db.Order_Details<br>
where ProductItems.OrderID == order_ID<br>
select ProductItems.ProductID;<br><br>
// Result query<br><br>
var myProducts = from p in db.Products<br>
where itemQuery.Contains(p.ProductID)<br>
select p; <br>