title: Join large list of Integers into LINQ Query
body: <p>I have LINQ query that returns me the following error:
  "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100".</p>
  
  <p>All I need is to count all clients that have BirthDate that I have their ID's in list.
  My list of client ID's could be huge (millions of records).</p>
  
  <p>Here is the query:</p>
  
  <pre><code>List&lt;int&gt; allClients = GetClientIDs();
  
  int total = context.Clients.Where(x =&gt; allClients.Contains(x.ClientID) &amp;&amp; x.BirthDate != null).Count();
  </code></pre>
  
  <p>When the query is rewritten this way,</p>
  
  <pre><code>int total = context
      .Clients
      .Count(x =&gt; allClients.Contains(x.ClientID) &amp;&amp; x.BirthDate != null);
  </code></pre>
  
  <p>it causes the same error.</p>
  
  <p>Also tried to make it in different way and it eats all memory:</p>
  
  <pre><code>List&lt;int&gt; allClients = GetClientIDs();
  
  total = (from x in allClients.AsQueryable()
           join y in context.Clients
           on x equals y.ClientID
           where y.BirthDate != null
           select x).Count();
  </code></pre>