title: C# find all matching Items from a List<Item>
body: <p>Let's say we have a <code>List&lt;Product&gt;</code> and each product item in the list has many <code>List&lt;Type&gt;</code> </p>
  
  <pre><code>public class Product{
  public int Id {get:set;}
  public string Name {get:set;}
  public List&lt;Type&gt; Types {get;set;}
  }
  
  public class Type{
  public int Id {get;set;}
  public string Name{get;set;}
  }
  </code></pre>
  
  <p>After I create a product list, I need to group them by the type and then find all the belongs to each type. I think I should try <code>LINQ</code> for this. Here is what I have done so far, but seems not the right way to get the job done. May be someone can help me. </p>
  
  <pre><code>var productsList = new List&lt;Product&gt;();
  //Adding products and types for each of them
  
  var productTypesList = new Dictionary&lt;int, string&gt;();
  
   foreach (var p in productsList)
                              {
                                  var pTypes = p.Types;
                                  foreach (var ptype in
                                      pTypes.Where(x=&gt; !productTypesList .ContainsKey(x.Id)))
                                  {
                                      productTypesList.Add(ptype.Id, ptype.Name);
                                  }
                              }
  </code></pre>
  
  <p>Then I'm trying to search Like this</p>
  
  <pre><code>foreach (var t in productTypesList)
  {
  var matches = productsList.FindAll(........); 
  // from here I need to find all the product which belongs to type (t.id)
  
  if (matches.Count &gt; 0)
  {
  //Do somthing here
  }
  }
  </code></pre>