Reputation: 9
I'm having a hard time converting this query to LINQ. Can you guys help me.
select ChoiceID, count(ChoiceID) as aValue
from QuestionNumber inner join
TestAnswer
on QuestionNumber.QNID = TestAnswer.QNID
where QuestionNumber.QuestionID = 30
group by ChoiceID
order by aValue desc
Thanks!
Upvotes: 0
Views: 121
Reputation: 6524
var query = from qNo in QuestionNumber
join tAnswer in TestAnswer on
qNo.QNID equals tAnswer.QNID into qAnswer
group qAnswer by qNo.ChoiceId
where qNo.QuestionId == 30
select new { ChoiceId = qNo.ChoiceId,
QCount = qAnswer.Count() }
orderby qAsnwer.QCount descending
Upvotes: 1