SQL-запрос -
select q.QuesId, q.Title, q.Description, count(a.QuesId) as Answers
from Question q
join Answer a on q.QuesId = a.QuesId
group by q.QuesId, q.Title, q.Description
Я хочу преобразовать этот запрос Sql в linq.
Мой подход -
var questions = (from q in db.Questions
join a in db.Answers on q.QuesId equals a.QuesId
group q by new
{ q.QuesId, q.Title, q.Description, q.AskedBy, q.AskedOn, q.ModifiedOn }
into x
select new
{ x.Key.QuesId, x.Key.Title, x.Key.Description, x.Key.AskedBy, x.Key.AskedOn, x.Key.ModifiedOn, x.key.Answers.count }
).ToList();
Кажется, он не работает.