title: how to filter linq expression for use with CodeSmith bulk update
body: <p>I'm using CodeSmith Plinqo's bulk update functionality with the following wrapper code:</p>
  
  <pre><code>public int Update&lt;TEntity&gt;(Expression&lt;Func&lt;TEntity, bool&gt;&gt; filter, 
      Expression&lt;Func&lt;TEntity, TEntity&gt;&gt; evaluator) where TEntity : class
  {
      var tbl = _dataContext.GetTable&lt;TEntity&gt;();
      return tbl.Update(filter, evaluator);
  }
  </code></pre>
  
  <p>Example Usage:</p>
  
  <pre><code>DCCore.Update&lt;Code&gt;(filter =&gt; _results.UpdatedCodes.Select(
      x =&gt; x.CodeID).Contains(filter.CodeID),
      u =&gt; new Code {
          CodeStatusID = EpcEvent.CodeStatusID.Value
      });
  </code></pre>
  
  <p>This works great except when the "filter" contains more than 2100 elements, then we get the sql server 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>What I'd like to do is enhance my Update wrapper so that it breaks the "filter" expression into 2000 item chunks.  Something like this pseudo code:</p>
  
  <pre><code>public int Update&lt;TEntity&gt;(Expression&lt;Func&lt;TEntity, bool&gt;&gt; filter, 
      Expression&lt;Func&lt;TEntity, TEntity&gt;&gt; evaluator) where TEntity : class
  {
      var tbl = _dataContext.GetTable&lt;TEntity&gt;();
      var index = 0;
      const int chunk = 2000;
      var filterCount = filter.Count();
      while (index * chunk &lt; filterCount)
      {
          var smallFilter = filter.Skip(index*chunk).Take(chunk);
          tbl.Update(smallFilter, evaluator);
          index++;
      }
      return filterCount;
  }
  </code></pre>