title: C# LINQ to Entities query for the intersection of two different properties
body: <p>I have 3 models named:</p>
  <blockquote>
  <p><strong>Pencil</strong> having Pencil.Id(int) and Pencil.Colors(IEnumerable) Property</p>
  <p><strong>Pen</strong> having Pen.Id(int) and Pen.Colors(IEnumerable) Property</p>
  <p><strong>Colors</strong> having Id and name.</p>
  </blockquote>
  <p>Pencil has a relation with colors (many-to-many)
  Pen has a relation with colors (many-to-many)</p>
  <p>I want to build a query which will show me the same colored pencils for the pen that I am holding.</p>
  <p>I am using the below LINQ-to-Entities query:</p>
  <pre><code>int id = id_of_the_pen_that_i_am_holding;
  Pen p = db.Pens.Find(id);
  var list = from m in db.Pencils where m.Colors.Intersect(p.Colors) != null select m;
  </code></pre>
  <p>Colors model is IEnumerable so it has more than 1 color. For example; the pen has 15 different colors and pencil is having 25 different colors. I want to bring the corresonding pencil if one of the colors of the pen that I am holding is also avaialable in the color palette of that pencil.</p>
  <p>But I am getting an exception to use regular variables like int or string rather than objects.</p>
  <p>What can I do? Thanks in advance for your helps.</p>
  <p><strong>EDITED:</strong>
  I've created a new question for a next possible issue: <a href="https://stackoverflow.com/questions/11760499/c-sharp-linq-to-entities-properties-on-the-intersection-set">C# LINQ to Entities- Properties on the intersection of an object and a collection of objects</a></p>