title: How to query a List<MyClass> with another list<int> into a new List<MyClass>
body: <p>I have two lists:</p>
  
  <pre><code>static List&lt;Parts&gt; partList = new List&lt;Parts&gt;();
  </code></pre>
  
  <p>The class it refers to:</p>
  
  <pre><code>class Parts
  {
      int chassisNumber;
  
      public int ChassisNumber
      {
          get { return chassisNumber; }
          set { chassisNumber = value; }
      }
  
      int partsCount;
  
      public int PartsCount
      {
          get { return partsCount; }
          set { partsCount = value; }
      }
  </code></pre>
  
  <p>And the another one:</p>
  
  <pre><code>static List&lt;int&gt; shuffledChassisList = new List&lt;int&gt;();
  </code></pre>
  
  <p>shuffledChassisList contains a subset of chassis numbers loaded into List ChassisNumber.
  I want to use shuffledChassisList to query the List into a new List, for ex: List filteredPartList.</p>
  
  <p>I tried to use Linq but failed to write a working solution that would create a new list with filtered results.</p>
  
  <p>Then, I want to use this filtered list to categorise parts into new lists depending on part number count (for ex: I want to copy all parts from List filteredPartList into List emptyPackageList where a Part's partsCount is 0).</p>
  
  <p>So far I got this, but not sure what to write in the foreach loop:</p>
  
  <pre><code>static List&lt;Parts&gt; emptyPackageList = new List&lt;Parts&gt;();
  
  var emptyPackage = filteredPartList.Where(p =&gt; p.partsCount == 0);
  
  foreach (var part in emptyPackage)
  {
      emptyPackageList.Add(new Parts(??));
  }
  </code></pre>
  
  <p>If it is possible to write one method that does this two thing one it is fine for me.</p>
  
  <p><strong>edit:</strong>
  The reason why I need to have two lists is because I query a database to get the chassis numbers and the parts count which belonging to it. I asked the community, but unfortunately it seems that it is not possible to make this query to run on selected chassis numbers. So I have the partscount for all the chassisnumbers (<code>List&lt;Parts&gt; partList</code>), which I need to filter with ones I am looking for (<code>List&lt;int&gt; shuffledChassisList</code>), then group by into new lists by partscount.</p>
  
  <p>If it is possible or easier to filter the <code>List&lt;Parts&gt; partList</code> by the <code>List&lt;int&gt; shuffledChassisList</code> then group by the results by partsCount and then copy the Parts into several new lists, then it is also an acceptable solution.</p>