title: web api and odata performance : perform query at database level
body: <p>I am using oData for a web api project. This is my code :</p>
  
  <pre><code>[HttpGet]        
  [EnableQuery]
  [Route("sessions")]
  public IQueryable&lt;Session&gt; Get()
  {
      var sessions = this.sessionRepository.GetAllSessions();
      return sessions.AsQueryable();        
  }
  
  public class Session
  {
      public long Id {get;set;}
  
      public string Name {get;set;}
  }
  </code></pre>
  
  <p>This is working well :</p>
  
  <p>When I call the api like this mydomain/api/sessions, I get all the sessions
  When I call the api like this mydomain/api/sessions?$filter=Name eq 'session test', I get only the sessions which has the name equals to 'session test'.</p>
  
  <p>The problem with this code, is that whatever the request performed by the user (no filter, filter, top, or anything else), a first "select *" is performed
  in db and then with the QueryableAttribute from oData, a filter is performed on the results got from the first big request "select *".
  My question is the following : is it possible to perform the query given by the user directly in the db and not doing first the select * and then performs the filter on this result.</p>
  
  <p>Thanks in advance for your help.</p>