How to convert following into LINQ query or Object Query?
SELECT ABC FROM dbo.TableOne
WHERE XID IN (SELECT YID FROM dbo.TableTwo
WHERE YId = 1 AND ZID2 = 2)
See Question&Answers more detail:osHow to convert following into LINQ query or Object Query?
SELECT ABC FROM dbo.TableOne
WHERE XID IN (SELECT YID FROM dbo.TableTwo
WHERE YId = 1 AND ZID2 = 2)
See Question&Answers more detail:osThe following should work. I have not compiled it so correct the syntax errors if any.
Also you should try these things by yourself first and then post.
from tab1 in TableOne
where
(
from xyz in TableTwo
where xyz.YId == 1 && xyz.ZID2 == 2
select xyz.YID
).Contains(tab1.XID)
select new { tab1.abc }
or for EF
var arrYID = (from xyz in TableTwo
where xyz.YId == 1 && xyz.ZID2 == 2
select xyz.YID).ToArray();
var objABC = from tab1 in TableOne
where arrYID.Contains(tab1.XID).select new {tab1.abc};