title: Linq with group by returning count 1 when when it should be 0
body: <p>I'm having a bit of a trouble with a linq query which counts the group by returns. For results that returns 0 in the MSSQL query, it's returning 1.
  Here is the LINQ:</p>
  
  <pre><code>from qs in Ctx.QS
  join qq in Ctx.QQ on qs.ID equals qq.QSID
  join qt in Ctx.QT on qq.QTID equals qt.ID
  join qv in Ctx.QV on qt.QID equals qv.QID
  join qi in Ctx.QI on qs.ID equals qi.QSID
  join r in Ctx.R on qi.ID equals r.QIID into r_1
  from rr in r_1.DefaultIfEmpty()
  where qv.ID == 1
  group qs by new { qsId = qs.ID, qtId = qt.ID, qt.Title, qs.Name, qi.Group } into g
  orderby g.Key.qsId
  orderby g.Key.qtId
  select new { g.Key.qsId, g.Key.qtId, g.Key.Title, g.Key.Name, g.Key.Group, Qty = g.Count() };
  </code></pre>
  
  <p>I'm trying to translate this SQL query:</p>
  
  <pre><code>SELECT qs.ID, qt.ID, qt.TITLE, qs.NAME, qi.GROUP, COUNT(r.ID)
  FROM AVLQS qs
  INNER JOIN AVLQQ qq ON qs.ID = qq.QSID
  INNER JOIN AVLQT qt ON qq.AVLQTID = qt.ID
  INNER JOIN AVLQV qv ON qt.AVLQID = qv.AVLQID
  INNER JOIN AVLQI qi ON qs.ID = qi.AVLQSID
  LEFT JOIN AVLR r ON qi.ID = r.AVLQIID
  WHERE qv.ID = 1
  GROUP BY qs.ID, qt.ID, qt.TITLE, qs.NAME, qi.GROUP
  ORDER BY qt.ID, qs.ID
  </code></pre>
  
  <p>The translation is almost 100%, the only difference I see is in the Count() function, but I can't find a way to do in LINQ what SQL does in COUNT(r.ID) because in LINQ the predicate that accepts inside Count() function expects "QS" and not (R).</p>
  
  <p>My case is a bit more complex than the one in the "duplicate" question because the object that is expected inside Count() in my case, doesn't know about the right sub-object that it should check inside Count().</p>