title: using the OData Queryable with a repository?
body: <p>I have this repository method:</p>
  
  <pre><code>public IQueryable&lt;TModel&gt; GetAll()
  {
      using (var context = new DatabaseContext())
      {
          return context.Set&lt;TModel&gt;().AsQueryable();
      }
  }
  </code></pre>
  
  <p>where <code>TModel</code> is an artist-model.. anyway</p>
  
  <p>And then I have this action in my controller:</p>
  
  <pre><code>// GET api/artist
  [Queryable]
  public IQueryable&lt;ArtistModel&gt; Get()
  {
      return _repo.GetAll().AsQueryable();
  }
  </code></pre>
  
  <p>Now.. if I would change the repository method to return a List and also add <code>.ToList</code> for my result.. then this would work great. But then no  matter what OData query comes in.. I would still first execute a "get all query".. turn them into a list and then I would execute my OData query against that list.. </p>
  
  <p>Which seems just plain wrong.. what I would like to do is to make sure that the OData query gets executed the same time as I'm trying to fetch data from the database.. so I only get the very specific result matching the query.. and not a huge bunch of data that then later on gets queried..</p>
  
  <p>For now I have the problem with the <code>DbContext</code> getting disposed once outside the using.. but I still need to close the <code>DbContext</code> as well some where, some how..</p>
  
  <p>Any ideas?</p>