title: Performance of repository pattern and IQueryable<T>
body: <p>I have no idea if I'm doing this right, but this is how a <code>Get</code> method in my repository looks:</p>
  
  <pre><code>    public IQueryable&lt;User&gt; GetUsers(IEnumerable&lt;Expression&lt;Func&lt;User, object&gt;&gt;&gt; eagerLoading)
      {
          IQueryable&lt;User&gt; query = db.Users.AsNoTracking();
  
          if (eagerLoading != null)
          {
              foreach (var expression in eagerLoading)
              {
                  query = query.Include(expression);
              }
          }            
          return query;
      }
  </code></pre>
  
  <p>Lets say I also have a <code>GeographyRepository</code> that has <code>GetCountries</code> method, which is similar to this.</p>
  
  <p>I have 2 separate service layer classes calling these 2 separate repositories, sharing the same DbContext (EF 4.1 code-first).</p>
  
  <p>So in my controller, I'd do:</p>
  
  <pre><code>myViewModel.User = userService.GetUserById(1);
  myViewModel.Countries = geoService.GetCountries();
  </code></pre>
  
  <p>This is 2 separate calls to the database. If I didn't use these patterns and tie up the interface and database, I'd have 1 call. I guess its something of a performance vs maintainability.</p>
  
  <p>My question is, can this be pushed to 1 database call? Can we merge queries like this when views calls multiple repositories?</p>