title: How to compare 2 lists of objects and remove the items that are not common?
body: <p>I've got 2 generic lists that do not contain the all fields of the same type</p>
  
  <pre><code>IList&lt;Category&gt; and List&lt;CategoriesRow&gt;Categories
  
  categoryList = IList&lt;Category&gt;
  </code></pre>
  
  <p>but both have common fields Name and ID.</p>
  
  <p>I want to compare list Categories with categoryList and find those from categoryList where categoryList[index].ID does not exist in the list of all Categories of ID. For all those that do not exist in Categories, I will have to remove them from CatgoryList.</p>
  
  <p>I had a previous post in which I was given examples of LINQ, but the problem is I have to use Dynamic, implying that I am passing categoryList and Categories as Dynamic.</p>
  
  <p>Can anyone give me an example how to go about the above as I have no idea how to do it.</p>