title: How to make LINQ join inside another LINQ query?
body: <p>I'm trying to do normal and easy join, but I always get this error.</p>
  <blockquote>
  <p>The LINQ expression 's' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See <a href="https://go.microsoft.com/fwlink/?linkid=2101038" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=2101038</a> for more information.</p>
  </blockquote>
  <p><strong>Models</strong></p>
  <p>Rooms</p>
  <pre><code>public class Room
  {
      public Guid Id { get; set; }
  
      //#nullable enable
      public Guid? postSubjectId { get; set; }
      [ForeignKey(&quot;postSubjectId&quot;)]
      public PostSubject postSubject { get; set; }
  
      //#nullable enable
      public string MemberId { get; set; }
      [ForeignKey(&quot;MemberId&quot;)]
      public AppUser Member { get; set; }
  
      //#nullable enable
      public Guid? GroupId { get; set; }
      [ForeignKey(&quot;GroupId&quot;)]
      public Group Group { get; set; }
  
  }
  </code></pre>
  <p>Groups</p>
  <pre><code>public class Group
  {
      public Guid Id { get; set; }
      public string GroupName { get; set; }
      public string GroupCode { get; set; }
      public virtual List&lt;Room&gt; rooms { get; set; }
  
  }
  </code></pre>
  <p><strong>ViewModel</strong></p>
  <pre><code>class LestGroup
  {
       public string GroupCode { get; set; }
       public string GroupName { get; set; }
       public string MemberId { get; set; }
       public string postSubjectId { get; set; }
       public string GroupId { get; set; }
  }
  </code></pre>
  <p><strong>LINQ</strong></p>
  <pre><code>        List&lt;Group&gt; groups = context.groups.ToList();
          List&lt;Room&gt; rooms = context.Rooms.ToList();
          List&lt;LestGroup&gt; GetRoomsJoinGroups = new List&lt;LestGroup&gt;();
  
          // First Query ... working well
          GetRoomsJoinGroups = rooms.Join(groups,
              R =&gt; R.GroupId,
              G =&gt; G.Id,
              (R, G) =&gt; new LestGroup
              {
                  GroupCode = G.GroupCode,
                  GroupName = G.GroupName,
                  MemberId = R.MemberId,
                  postSubjectId = R.postSubjectId.ToString(),
                  GroupId = R.GroupId.ToString()
              }).ToList();
  
          // Second Query ... gives the mintioned error
          var GetSubjects = context.postSubjects
               .Include(i =&gt; i.postContents)
               .Include(i =&gt; i.rooms)
               .Select(s =&gt; new
               {
                   PostCount = s.postContents.Count(),
                   RoomCount = s.rooms.Count(),
                   SubjectId = s.Id,
                   SubjectIcon = s.subjectIcon,
                   SubjectName = s.subjectName,
                   roms = GetRoomsJoinGroups.Where(w =&gt; s.rooms.Select(s =&gt; s.GroupId.ToString()).ToList().Contains(w.GroupId) )
               });
  </code></pre>
  <p>if i use <code>s.rooms</code> instead of <code>roms = GetRooms.Where(w =&gt; s.rooms.Select(s =&gt; s.GroupId.ToString()).ToList().Contains(w.GroupId) )</code> it returns Rooms and it works will, but for this particular part i want to make join between <code>Rooms</code> and <code>Groups</code></p>