title: Linq selecting parent based on child criteria
body: <p>The big picture: </p>
  
  <p>I'm working on a search form where the user can choose one or more criteria to filter the search results. One of the criteria is related to a child relationship.</p>
  
  <p>I'm trying to create an extention method to <code>Iqueryable&lt;Parent&gt;</code> so I can use as part of my "chaining".</p>
  
  <p>The method signature (as of now) is:</p>
  
  <pre><code>public static IQueryable&lt;Parent&gt; ContainsChild(this IQueryable&lt;Parent&gt; qry, int[]  childrenIDs)
  </code></pre>
  
  <p>The parent table and a child table:</p>
  
  <pre><code>Parent
    ParentID
    Name
    Description
  
  Child
    ParentID (FK)
    AnotherID (from a lookup table)
  
  Selection criteria:
  int[] ids = new int[3] {1,2,3}; 
  </code></pre>
  
  <p>Usage would be something like this:</p>
  
  <pre><code>var parents = repository.All() //returns Iqueryable&lt;Parent&gt;
  public IQueryable&lt;Parent&gt; Search(Search seach){
     if (search.Criteria1 != null){
        parents = parents.FilterByFirstCriteria(search.Criteria1);
     }
     if (search.ChildrenIDs != null){ //ChildrenIDs is an int[] with values 1,2,3
        parents = parents.ContainsChild(search.ChildrenIDs)
     }
  }
  </code></pre>
  
  <p>What I'm trying to figure out is how to create the ContainsChild method that returns an <code>IQueryable&lt;Parent&gt;</code> where the parents have at least one child with the <code>AnotherID</code> in the <code>ids</code> array.</p>
  
  <p>(I'm trying to use EF4 to accomplish this)</p>
  
  <p>Any help fully appreciated.</p>