title: How to retrieve(get) huge amount of data using linq(Entity Framework 5) with faster time
body: <p>One of the order in our database has huge amount of records(> 500,000). When I attempted to get all records and map them to domain model, Its taking forever (linq call). The following sample code will describe what I did...</p>
  
  <pre><code>int OrderId = 123456;
  int pagesize = 100;
  
  using (var dbContext = new MyDbContext())
  {
      var orderDetails = dbContext.orderDetailEntity
          .Where(i =&gt; i.Orders.OrderID == OrderId)
          .OrderBy(o =&gt; o.orderDetailStatus);
  
      var orderDetailModel = Mapper
          .Map&lt;IEnumerable&lt;OrderDetailModel&gt;&gt;(orderDetails.Take(PageSize));         
   }
  </code></pre>
  
  <p>For more information Orders entity and OrderDetail entity has relationships. So on the above query I am trying to get all OrderDetail for the specific. But It is taking forever cos of huge amount of data(More than half a million records).</p>
  
  <p>Do you have any idea how to solve this issue? 
  I really appreciate you </p>
  
  <p>Thank you in advance. </p>