Can anyone LINQ the following SQL?
I've been on this for two hours now and am no closer to getting this than I was when I started.
SELECT ArticleId, sum(Amount) AS VoteCount
FROM ArticleVotes INNER JOIN
Votes ON ArticleVotes.voteId = Votes.id
GROUP BY ArticleVotes.articleId
ORDER BY VoteCount DESC
Tables as follows;
ArticleVotes: ArticleId, VoteId
Votes: id, amount
I'm not entirely sure about the orderby part, for the matter, I'm not sure about the rest either, as I'm not in the position to test it. If it doesn't work, don't blame me please :)
Update: Using the OP's work:
Edit fixed the orderby to use descending ordering.
Thanks to the op giving me reason to use the let operator, and finally realizing its beauty. You helped me immensely with your question, just by asking it. +1 for that.
This is what i have now but it's missing the order by the total.
Try the following code. Because it was working for me.