title: Which types should my Entity Framework repository and service layer methods return: List, IEnumerable, IQueryable?
body: <p>I have a concrete repository implementation that returns a IQueryable of the entity:</p>
  
  <pre><code>public class Repository
  {
      private AppDbContext context;
  
      public Repository()
      {
          context = new AppDbContext();
      }
  
  
      public IQueryable&lt;Post&gt; GetPosts()
      {
          return context.Posts;
      }
  }
  </code></pre>
  
  <p>My service layer can then perform LINQ as needed for other methods (where, paging, etc)</p>
  
  <p>Right now my service layer is setup to return IEnumerable:</p>
  
  <pre><code>public IEnumerable&lt;Post&gt; GetPageOfPosts(int pageNumber, int pageSize)
  { 
      Repository postRepo = new Repository();
  
      var posts = (from p in postRepo.GetPosts()  //this is IQueryable
                  orderby p.PostDate descending
                  select p)
                  .Skip((pageNumber - 1) * pageSize)
                  .Take(pageSize);
  
      return posts;
  }
  </code></pre>
  
  <p>This means in my codebehind I have to do a ToList() if I want to bind to a repeater or other control.</p>
  
  <p>Is this the best way to handle the return types or do I need to be converting to list before I return from my service layer methods?</p>