title: In linq to entity, how to retrieve objects matching a list of conditions without looping?
body: <p>I play with a mysql database using ADO entity framework (through devart dot.connect).</p>
  
  <p>I get lists of entity objects (a) from listboxs and I would like to make a linq query retrieving all object from a given entity table (b) where there is a b foreign key:</p>
  
  <pre><code>//THIS WORKS :
  IQueryable&lt;Nb_student&gt; nbstud = MainForm.context.Nb_student_set;
  IQueryable&lt;Cat_student&gt; catstud = MainForm.context.Cat_student_set.Where(c =&gt; c.id == 2);
  
  var test1 = from nb in nbstud
              join bb in catstud on nb.cat_student_id equals bb.id
              select nb;
  </code></pre>
  
  <p>=> this gives me only matching nb_students (this is what I want...)</p>
  
  <p>Now, suppose instead of catstud, I have a list populated through a listbox.</p>
  
  <pre><code>IEnumerable&lt;Cat_student&gt; catstud2 = param_cat_students.AsEnumerable();
  var ttt2 = from nb in nbstud
             join bb in catstud2 on nb.cat_student_id equals bb.id
             select nb;
  </code></pre>
  
  <p>=> it does't work, the error is the following: {"Unable to create a constant value of type 'System.Collections.Generic.IEnumerable`1'. Only primitive types ('such as Int32, String, and Guid') are supported in this context."}
  it seems there is a problem with the ids (int32) for the join ???</p>
  
  <p>More generally, my question is : In Linq to Entity, how to select items from a table matching various lists of criterias (lists are not knowed in advance since they are choosen by the users) without making lot of loops. I thougth Join was the solution, I also tried the .any and .contains syntaxes without success :</p>
  
  <pre><code>var tt3 = from nb in nbstud.Where
            (nbx =&gt; catstud2.Any(cat =&gt; cat.id == nbx.cat_student_id)
            select nb;
  </code></pre>
  
  <p>If you could advice me... This is I suppose a very common problem but I don't know how to proceed.
  Thanking you in advance,</p>
  
  <p>Pierre</p>