title: Include() vs Select() performance
body: <p>I have a parent entity with a navigation property to a child entity. The parent entity may not be removed as long as there are associated records in the child entity. The child entity can contain hundreds of thousands of records.</p>
  
  <p>I'm wondering what will be the most efficient to do in Entity Framework to do this:</p>
  
  <pre><code>var parentRecord = _context.Where(x =&gt; x.Id == request.Id)
                             .Include(x =&gt; x.ChildTable)
                             .FirstOrDefault();
  
  // check if parentRecord exists
  
  if (parentRecord.ChildTable.Any()) {
    // cannot remove
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>var parentRecord = _context.Where(x =&gt; x.Id == request.Id)
                              .Select(x =&gt; new {
                                    ParentRecord = x,
                                    HasChildRecords = x.ChildTable.Any()
                              })
                             .FirstOrDefault();
  
  // check if parentRecord exists
  
  if (parentRecord.HasChildRecords) {
    // cannot remove
  }
  </code></pre>
  
  <p>The first query may include thousands of records while the second query will not, however, the second one is more complex.</p>
  
  <p>Which is the best way to do this?</p>