I have 3 models named:
Pencil having Pencil.Id (int) and Pencil.Colors (IEnumerable) Property
A pen that has the Pen.Id (int) and Pen.Colors (IEnumerable) property
Colors with identifier and name.
Pencil is related to colors (many-to-many) Pen is related to colors (many-to-many)
I want to create a query that will show me the same colored pencils for a pen as I do.
I am using the following LINQ to-Entities query:
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;
IEnumerable, . ; 15 , 25 . , , , .
, int string, .
? .
:
: # LINQ to Entities -