title: LINQ - Different results with LINQ to SQL vs LINQPad
body: <p>I am executing the "same" query using LINQ to SQL and in LINQPad, however the result set comes out slightly differently.</p>
  
  <p>The code is</p>
  
  <pre><code>var conn = new SqliteConnection (
              "DbLinqProvider=Sqlite;" + 
              "Data Source=/home/larsenma/database.golden"
          );
  
  Models.Main db = new Models.Main (conn);
  
  var runSum =
    from rr in db.Runrecords
    group rr by rr.RunID into rg          
    select new 
    {
      LaneCount = rg.Count(),
    }
  </code></pre>
  
  <p>LINQPad properly calculates the "LaneCount" while with LINQ to SQL I get 1s for each record.</p>
  
  <p>With LINQ to SQL I used sqlmetal to generate my mapping for DBLinq and with LINQPad is used the IQ driver.  My database is SQLite.</p>
  
  <p>I'm rather new to this LINQ stuff, any ideas where I am going wrong?</p>
  
  <p><strong>EDITS</strong></p>
  
  <p>I've simplified my query to the minimalist reproducible instance.   When I debug the generated SQL I get</p>
  
  <pre><code>SELECT (SELECT COUNT(*))
  FROM runrecords
  GROUP BY RunID
  </code></pre>
  
  <p>It is the second "COUNT(*)" that is missing things up. </p>
  
  <p>Thanks.</p>