title: DataContext Accessed After Dispose
body: <p>I'm using ASP.NET 4.0.</p>
  
  <p>I've got the following code that returns with an error of "Cannot access a disposed object.
  Object name: 'DataContext accessed after Dispose.'."</p>
  
  <pre><code> public IEnumerable&lt;BatchHeader&gt; GetHeaders()
              {
                  using(NSFChecksDataContext context = DataContext)
                  {
                      IEnumerable&lt;BatchHeader&gt; headers = (from h in context.BatchHeaders
                                                          select h);                
                      return headers;                            
                  }
              }
  </code></pre>
  
  <p>If I change this to:</p>
  
  <pre><code>public IEnumerable&lt;BatchHeader&gt; GetHeaders()
          {
              using(NSFChecksDataContext context = DataContext)
              {            
                  return context.BatchHeaders.ToList();                            
              }
          }
  </code></pre>
  
  <p>It will work fine.  I'm using this method to populate a RadGrid.  Can anyone explain why the second method will work but not the first?</p>
  
  <p>Thanks.</p>