title: How to return IQueryable from an oData V4 api action
body: <p>Following the tutorial <a href="https://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint" rel="nofollow noreferrer">here</a> I'm trying to return IQueryable but I get error <em>The operation cannot be completed because the DbContext has been disposed</em> </p>
  
  <pre><code>public class ProductsController : ODataController
  {
      [EnableQuery]
      public IQueryable&lt;Product&gt; Get()
      {
          return GetRepository&lt;Product&gt;().GetQueryable();
      }
  }
  </code></pre>
  
  <p>GetRepository() is part of a larger generic DI and Unit of work pattern class that basically</p>
  
  <pre><code>public Repository(DbContext context)
  {
      Context = context;
      DbSet = Context.Set&lt;T&gt;();
  }
  
  public virtual IQueryable&lt;T&gt; GetQueryable()
  {
      IQueryable&lt;T&gt; query = DbSet;
  
      return query;
  }
  </code></pre>