title: Linq: Nested queries are better than joins, but what if you use 2 nested queries?
body: <p>In her book <a href="http://books.google.co.uk/books?id=rtdgHbMeTBMC&amp;pg=PA92&amp;lpg=PA92&amp;dq=entity%20framework%20nested%20queries&amp;source=bl&amp;ots=kUxh3DJtZD&amp;sig=YRv2VJlHTHaFq9WgMz7j8tuSIiU&amp;hl=en&amp;ei=-O4BTZPMINH5sga01rzwCQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=6&amp;ved=0CD4Q6AEwBQ#v=onepage&amp;q=entity%20framework%20nested%20queries&amp;f=false" rel="nofollow">Entity Framework Julie Lerman</a> recommends using nested queries in preference to joins (scroll back a couple of pages).
  In her example see populates 1 field this way, but what id you want to populate 2?</p>
  
  <p>I have an example here where I would prefer to populate the Forename and Surname with the same nested query rather than 2 separate ones. I just need to know the correct syntax to do this.</p>
  
  <pre><code>public static List&lt;RequestInfo&gt; GetRequests(int _employeeId)
  {
      using (SHPContainerEntities db = new SHPContainerEntities())
      {
          return db.AnnualLeaveBookeds
              .Where(x =&gt; x.NextApproverId == _employeeId ||
              (x.ApproverId == _employeeId &amp;&amp; x.ApprovalDate.HasValue == false)) 
              .Select(y =&gt; new RequestInfo
              {
                  AnnualLeaveDate = y.AnnualLeaveDate,
                  Forename = (
                      from e in db.Employees 
                      where e.EmployeeId == y.EmployeeId 
                      select e.Forename).FirstOrDefault(),
                  Surname = (
                      from e in db.Employees 
                      where e.EmployeeId == y.EmployeeId 
                      select e.Surname).FirstOrDefault(),
                  RequestDate = y.RequestDate,
                  CancelRequestDate = y.CancelRequestDate,
                  ApproveFlag = false,
                  RejectFlag = false,
                  Reason = string.Empty
              })
              .OrderBy(x =&gt; x.AnnualLeaveDate)
              .ToList();
      }
  }
  </code></pre>