title: Why doesn't Web API Controller with LINQ To SQL and "using" statement work?
body: <p>I like to wrap my data access in using statements to make myself feel good about garbage collection. I am running Visual Studio 2013 Preview and targeting .NET 4.5. I have an ApiController called WordsController as such:</p>
  
  <pre><code>public class WordsController : ApiController
  {
      // GET api/&lt;controller&gt;
      public IEnumerable&lt;Keyword&gt; Get()
      {
          using (TestDataContext dc = new TestDataContext())
          {
              return dc.Keywords;
          }
      }
  }
  </code></pre>
  
  <p>I get an error telling me that the datacontext has been disposed before accessing the data.</p>
  
  <p>Changing the code to this works:</p>
  
  <pre><code>public class WordsController : ApiController
  {
      // GET api/&lt;controller&gt;
      public IEnumerable&lt;Keyword&gt; Get()
      {
          TestDataContext dc = new TestDataContext();
  
          return dc.Keywords;
      }
  }
  </code></pre>
  
  <p>Why does this work when not <code>using</code> the DataContext?</p>