title: Linq query for two tables using SUM and Group By
body: <p>I have two tables </p>
  
  <p>Replies</p>
  
  <pre><code>|ReplyID     |ReplyText | QuestionID | CreatedOn  |
  |1           |xxxxxx    |1           | 01/01/2016 |
  |2           |yyyyyy    |2           | 02/01/2016 |
  |3           |zzzzzz    |3           | 03/01/2015 |
  </code></pre>
  
  <p>and Votes</p>
  
  <pre><code>|ReplyID     |VoteValue |UserId   |
  |1           |1         |1        |
  |1           |1         |2        |
  |2           |-1        |3        |
  |3           |1         |4        |
  </code></pre>
  
  <p>I m trying to join two tables on ReplyIds against id value which I m getting as a controller parameter. </p>
  
  <p>This is the linq query I m using:</p>
  
  <pre><code>Replies = from r in db.Replies
            join v in db.Votes on r.ReplyID equals v.ReplyId
            where r.QuestionId == id
            orderby r.CreatedOn descending
            group v by v.ReplyId into g
            select g.Key
  </code></pre>
  
  <p>where Replies is </p>
  
  <pre><code>public IGrouping&lt;Reply, Vote&gt; Replies { get; set; }
  </code></pre>
  
  <p>I m having this error:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'System.Linq.IQueryable' to System.Linq.IGrouping'</p>
  </blockquote>
  
  <p>I m unable to proceed from here. I need to Sum(VoteValues) in Votes table and join it with Replies table to get all column values. Any help would be appreciated.</p>