I have gone through couple of similar questions but couldn't find what I wanted.
I need to find tags which has a ID in Answers table, since there could be multiple answers records containing the tag ID I need to take care of the duplicates. This is the reason why I cant perform simple join.
I thought about using an EXISTS but couldn't figure out the way to do it yet.
This is the working SQL
SELECT DISTINCT TagName
FROM Tags tag
JOIN Answers ans ON ans.StID = tag.Id
WHERE tag.SchId = 472
AND ans.isValid = 1
This is what I tried in LINQ with no success
(from tag in Tags
where tag.Id.Any(from ans in Answers
where ans.StID == tag.Id
&& tag.SchId == 472
&& ans.isValid == true
select ans.ID)
select tag.TagName
It would be helpful if someone can suggest a way to correctly implement this query in LINQ.