title: Querying MongoDB with List of IDs using Lambda Expression
body: <p>I'm hoping someone can help me:</p>
  
  <p>I'm using an interface to access my data, the Find method is:</p>
  
  <pre><code>public IQueryable&lt;T&gt; Find&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; expression) where T : class, new()
      {
          return (IQueryable&lt;T&gt;) _db.GetCollection&lt;T&gt;(typeof(T).Name, WriteConcern.Acknowledged).AsQueryable().Where(expression);
      }
  </code></pre>
  
  <p>I'm trying to build an expression to fetch all ObjectIds within a list of ObjectIds.</p>
  
  <p>something like:
  r => r.id.ContainsAny(List_Of_IDs); //where List_Of_IDs is of type: List</p>
  
  <p>I also tried:
  r => r.id.ContainsAny(new[] {id1, id2, id3}) //where id1, id2, id3 are type ObjectId</p>
  
  <p>But I get an error that ContainsAny doesn't support this parameter.</p>
  
  <p>I was hoping to duplicate the functionality of an IN statement in SQL. My goal is that I want the user collection to contain a list of products as a list of ObjectIds and then I want to query the products collection and get all documents in the user's list of Product IDs.</p>
  
  <p>Is this possible? Does anyone know what I'm doing wrong?</p>
  
  <p>Thanks so much for any assistance!
  Steve</p>
  
  <p>BTW: here is where I send the expression to the repository method:</p>
  
  <pre><code>public static List&lt;product&gt; getByIDlist(List&lt;ObjectId&gt; IDs)
      {
          return (List&lt;product&gt;)repo.Find&lt;product&gt;(r =&gt; r.id.ContainsAny(IDs));       
      }
  </code></pre>