title: Paging Entities (of Aggregates) in Repository with Entity Framework (EF)
body: <p>Suppose I have the following aggregate root:</p>
  
  <pre><code>public class Aggregate
  {
      public int Id {get; set;}
  
      public List&lt;Entity&gt; Entities {get; set;}
  }
  </code></pre>
  
  <p>And the following repository:</p>
  
  <pre><code>public class AggregateRepository
  {
     public Aggregate GetPaged(int Id)
     {
       return db.Aggregate
                .Include(x=&gt;x.Entities)
                .Find(id)             
     }
  }
  </code></pre>
  
  <p><strong>Question</strong>: how can I get a paged and sort list of entities? Which is the best approach to get the entities paged and sorted, but also with the aggregate information?</p>
  
  <p><strong>Edited:</strong></p>
  
  <p>What are you think about the following approach?</p>
  
  <pre><code>public class AggregateRepository
      {
         public IEnumerable&lt;Entity&gt; GetEntitiesPaged(int id)
         {
           return db.Aggregate
                    .Include(x=&gt;x.Aggregate)
                    .Where(x=&gt;x.Id = id)
                    .Select(x=&gt;x.Entities)
                    .Take(20);        
         }
      }
  </code></pre>
  
  <p>Instead of return an aggregate object, I can receive a list of entities (20 entities, in this case) with aggregate object included. Is it a good approach working with an aggregate in DDD pattern?</p>