Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If one of the various duplicate answers doesn't help, <a href="http://geekswithblogs.net/EltonStoneman/archive/2010/07/11/where-in-style-queries-in-linq-to-entities.aspx" rel="nofollow">here is a link</a> to one that might. It references an extension to Linq-to-entities:</p> <pre><code>public static class QueryExtensions { public static IQueryable&lt;TEntity&gt; WhereIn&lt;TEntity, TValue&gt; ( this ObjectQuery&lt;TEntity&gt; query, Expression&lt;Func&lt;TEntity, TValue&gt;&gt; selector, IEnumerable&lt;TValue&gt; collection ) { ParameterExpression p = selector.Parameters.Single(); //if there are no elements to the WHERE clause, //we want no matches: if (!collection.Any()) return query.Where(x=&gt;false); if (collection.Count() &gt; 3000) //could move this value to config throw new ArgumentException("Collection too large - execution will cause stack overflow", "collection"); IEnumerable&lt;Expression&gt; equals = collection.Select(value =&gt; (Expression)Expression.Equal(selector.Body, Expression.Constant(value, typeof(TValue)))); Expression body = equals.Aggregate((accumulate, equal) =&gt; Expression.Or(accumulate, equal)); return query.Where(Expression.Lambda&lt;Func&lt;TEntity, bool&gt;&gt;(body, p)); } } </code></pre> <p>There are several others like it available.</p> <p><strong>EDIT</strong></p> <p>I've provided context for the code above, and here is possible usage:</p> <pre><code>db.SA_Opleiding.WhereIn(v =&gt; v.SomeCollection); </code></pre> <p>I haven't ever used this specific extension method, but they're all basically based on the same principle.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload