title: Linq to Objects - Where search within a list
body: <p>Linq to Objects - Where search within a list</p>
  
  <pre><code>    internal class ProdQtyByWarehouse
      {
          public int id { get; set; }
          public List&lt;ProdWarehouseQty&gt; ProdWarehouseQtys { get; set; }
      }
  
      internal class ProdWarehouseQty
      {
          public int id { get; set; }
          public string PName { get; set; }
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {
          var list1 = new List&lt;ProdWarehouseQty&gt;
                          {
                              new ProdWarehouseQty
                                  {
                                      id = 3,
                                      PName = "list1PN1"
                                  },
                              new ProdWarehouseQty
                                  {
                                      id = 4,
                                      PName = "list1PN2"
                                  }
  
                          };
          var list2 = new List&lt;ProdWarehouseQty&gt;
                          {
                              new ProdWarehouseQty
                                  {
                                      id = 5,
                                      PName = "list2PN1"
                                  },
                              new ProdWarehouseQty
                                  {
                                      id = 6,
                                      PName = "list2PN2"
                                  }
  
                          };
          var prodQtyByWarehouses = new List&lt;ProdQtyByWarehouse&gt;
                                        {
                                            new ProdQtyByWarehouse {id = 1, ProdWarehouseQtys = list1},
                                            new ProdQtyByWarehouse {id = 1, ProdWarehouseQtys = list2}
  
                                        };
          List&lt;int&gt; integers = new List&lt;int&gt;{2,3,4,6};
  
          List&lt;ProdQtyByWarehouse&gt; list =
              (from c in prodQtyByWarehouses
               where c.ProdWarehouseQtys.Contains(new ProdWarehouseQty {id = 3})
               select c).ToList(); // no object is returned
      }
  </code></pre>
  
  <p>How can i achieve: </p>
  
  <pre><code>List&lt;ProdQtyByWarehouse&gt; list =
              (from c in prodQtyByWarehouses
               where c.ProdWarehouseQtys.Contains(new ProdWarehouseQty {id in integers})
               select c).ToList();
  </code></pre>