title: How to group join with linQ
body: <p>I need to join two lists by an Id in order to map values to an User entity.</p>
  
  <p>For that part, I think I've managed to do it with : </p>
  
  <pre><code> var concernedParticipantIds = baseValues.Select(x =&gt; x.ParticipantId).Distinct().ToList();
                  var queryParticipants =_unitOfWorkMt.GetMTReadonly&lt;Participant&gt;().GetQuery(tenantId).Where(x =&gt; concernedParticipantIds.Contains(x.Id));
  
                  var participantAndValues = from value in baseValues
                      join participant in queryParticipants on value.ParticipantId equals participant.Id 
                      select new {Participant = participant, Value = value};
  </code></pre>
  
  <p>But it results in one line per Value like this :</p>
  
  <pre><code>user_1 =&gt; value_1
  user_1 =&gt; value_2
  user_1 =&gt; value_3
  user_2 =&gt; value_1
  user_2 =&gt; value_2
  user_2 =&gt; value_3
  ...
  </code></pre>
  
  <p>Is there a way to group by the user? I'd like something like :</p>
  
  <pre><code>- user_1 =&gt; value_1  
            value_2
            value_3
  - user_2 =&gt; value_1
            value_2
            value_3
  </code></pre>
  
  <p>The only thing I came up with is something like </p>
  
  <pre><code> var results = from p in participantAndValues
                 group p.Value by p.Participant into temp
                 select new { Person = temp.Key, Values = temp.ToList() };
  </code></pre>
  
  <p>Seems to work but not sure it's the right way, and maybe there's a way to do it in one query?</p>