我正在使用LINQPad来完成以下任务:
SELECT TOP 1000
q.Id as 'Question id', c.Id as 'Choice Id', c.Content as 'Choice Content', count(*) as 'Answer count'
FROM Answers a
join Choices c on
a.ChoiceId = c.id
join Questions q
on c.QuestionId = q.Id
group by q.Id, c.Id, c.Content
到目前为止我有这个但是无法弄清楚如何分组,特别是如果加入了多个表:
(
from a in Answers
join c in Choices
on a.ChoiceId equals c.Id
join q in Questions
on c.QuestionId equals q.Id
select new { q.Id, c.QuestionId, c.Content}
)