title: Join array to EF query
body: <p>I get the following error when trying to join an array to the Linq-to-EF query</p>
  
  <blockquote>
    <p>An error occurred while executing the command definition. See the inner exception for details. Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.</p>
  </blockquote>
  
  <p>The code is as follows:</p>
  
  <pre><code>var vids = new List&lt;string&gt;();
  using (var ctx = new MyDbContext())
  {
      var qry = ctx.Pickups.Where(p =&gt; p.UserName == User.Identity.Name);
      if (someBoolean)
      {
          var v = GetVids(); // get the list of Ids from a web service
          vids.AddRange(v);
      }
      if (vids.Count() &gt; 0)
      {
          qry = qry.Join(vids, p =&gt; p.VId, v =&gt; v, (v, p) =&gt; p);
      }
      var data = qry
          .Select(p =&gt; new
          {
              // etc.
          });
  }
  </code></pre>
  
  <p>The problem is that the web service is not associated with the DB I'm using EF with, otherwise, I'd just do the join against the tables in the DB. The number of Id's I get back from the web service could be upwards of a hundred or so (usually 5-10). If I comment out the Join, the code works fine, so I know the error is in the Join.  With just a few (up to about 30) ids in vids, the join works perfectly.</p>
  
  <p>What do you recommend to remedy this problem?  The only thing I could think of was to insert the list of IDs into the DB and do the join that way.  That doesn't seem too appealing to me.</p>