title: Linq Group by Values in a list
body: <p>So Currently I have this TrackingInfo class which contains an ID and a list of EmailActionIDs, which is an int.
  I have a List Of this class which the data looks like:</p>
  
  <pre><code>ID,   |   EmailActions
  _______________
   A    |   1, 3, 5
   B    |   3, 5, 6
   C    |   2, 4, 6
  </code></pre>
  
  <p>I'm trying to write a Linq Statement To convert this into  A list of IDs grouped by each individual value in the list.</p>
  
  <p>So the Results Set would look like:</p>
  
  <pre><code>ID   |   Values
  _______________
   1    |   A
   2    |   C
   3    |   A, B
   4    |   C,
   5    |   A, B
   6    |   B, C
  </code></pre>
  
  <p>I can't figure out how I would write the group by can anyone give me some insight.</p>
  
  <pre><code>DistinctValues = new List&lt;int&gt; {1,2,3,4,5,6};
  TrackingInfo.Groupby(t =&gt; DistinctValues.foreach(d =&gt; 
                                             t.EmailActions.Contains(d))).Tolist()
  </code></pre>
  
  <p>This ofcourse isn't working any suggestions on how to do this using Linq</p>