Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to linq,i am using sub query.I want to convert the below sql query into linq query.


SQL
Select [Color] from [eshop_db].[dbo].[ProductInfoView] where [ProductID] in(
Select ProductId from [old_eshop_db].[dbo].[ProductMaster] where [SKU] in (
Select [SKU] from [old_eshop_db].[dbo].[ProductMaster] where ProductId=956));


Please any body help me out.
Posted

Use tools like LINKPad[^]. Learn, practice, use!
 
Share this answer
 
Comments
Karthik Harve 28-Oct-13 8:17am    
5!! nice one !!
try like below:
C#
var Color = FROM P IN ProductMaster
JOIN Co IN
    (
        FROM C IN ProductInfoView SELECT new {Color=C.Field<string>("Color"), ProducID=C.Field<int>("ProductID")}
    ) 
ON Co.ProducTID Equals P.Field<int>("ProducID) 
WHERE P.Field<int>("ProductID")==956
SELECT Co.Color;


hope it works.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900