title: With Entity Framework Core 5, how to nest a query and still have an IQueryable?
body: <p>I have two entities that I want to combine and return just one <code>IQueryable</code> from it. That is, as an example, think of a conference app where I have <code>Speakers</code> and <code>Sessions</code> and <code>Events</code>.</p>
  <p>If I do a big join of all three and then I ask for all the sessions associated with one speaker (across all events), I get a return record for every event when in reality I just want one speaker record with all the sessions as detail.</p>
  <p>That is, my EF query would look like this:</p>
  <pre><code>var q1 = from speaker in db.speakers
           join sessions in db.sessions on speaker.Id equals session.speakerId
           join event in db.sessions on session.EventId equals event.Id
           where speaker.Id = 101
  </code></pre>
  <p>What I want is something like the ability to first, create a speaker query</p>
  <pre><code>var q2 = from speaker in db.speakers
           where speaker.Id = 101
  </code></pre>
  <p>Then, create another query that gives me all the speakers sessions over all years</p>
  <pre><code>var q3 = join sessions in db.sessions on speaker.Id equals session.speakerId
           join event in db.sessions on session.EventId equals event.Id
           where session.AttendeeId = 101
  </code></pre>
  <p>and finally, I'm really looking for one query, qFinal that combines them.</p>
  <pre><code>var qFinal = q2 that has a collection of sessions, or basically, what q3 returns.
  </code></pre>
  <p>Keeping in mind that the <code>Attendee</code> entity contains a collection of sessions.</p>
  <p>I realize that my pseudo code above does not really compile but my real problem is much more complex and I thought it easier to explain in simpler terms.</p>