title: Left join with LINQ Error
body: <p>I'm new to linq so would appreciate your help with getting this left join query to work. </p>
  
  <p>I have "List hours" (a list of hours 0-23) that I'd like to left join with "var hourlyData" (a processed linq query containing aggregated data). My attempt at the left join  is "var reportData". </p>
  
  <pre><code>DataSet ds = GetDataSet(sSql);
  var stats = ds.Tables[0].AsEnumerable();
  
  var hourlyData = from stat in stats
                   group stat by stat.Field&lt;int&gt;("Hour") into g
                   select new
                   {
                       Hour = g.Key,
                       Value = g.Key.ToString(),
                       D1 = g.Sum(stat =&gt; stat.Field&lt;int&gt;("D1")),
                       D2 = g.Sum(stat =&gt; stat.Field&lt;int&gt;("D2")),
                       D3 = g.Sum(stat =&gt; stat.Field&lt;decimal&gt;("D3"))
                   };
  
  
  List&lt;int&gt; hours = new List&lt;int&gt;();
  for (int i = 0; i &lt; 24; i++)
  {
      hours.Add(i);
  }
  
  
  var reportData = from hour in hours.AsEnumerable()
                   join stat in hourlyData.AsEnumerable()
                       on hour equals stat.Hour 
                   into sts2
                   from stat2 in sts2.DefaultIfEmpty()
                   select new
                   {
                       Hour = hour,
                       Value = hour,
                       D1 = stat2.D1 != null ? stat2.D1 : 0,
                       D2 = stat2.D2 != null ? stat2.D2 : 0,
                       D3 = stat2.D3 != null ? stat2.D3 : 0
                   };
  </code></pre>
  
  <hr>
  
  <p>The code above produces this error:</p>
  
  <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <p>Source Error: </p>
  
  <pre><code>Line 135:                            into sts2
  Line 136:                         from stat2 in sts2.DefaultIfEmpty()
  Line 137:                         select new
  Line 138:                         {
  Line 139:                             Hour = hour,
   ...
  </code></pre>
  
  <p>Thanks!</p>