title: c# add parameters to Func
body: <p>I have these functions:</p>
  
  <pre><code>public List&lt;int&gt; GetInts(int someParam)
  public List&lt;int&gt; GetMoreInts(int someParam, int anotherParam)
  </code></pre>
  
  <p>I changed the signature of these functions so that they will get an additional optional parameter:</p>
  
  <pre><code>public List&lt;int&gt; GetInts(int someParam, int offset = 0)
  public List&lt;int&gt; GetMoreInts(int someParam, int anotherParam, int offset = 0)
  </code></pre>
  
  <p>Now, I want to call a wrapper function, which will call these functions with the additional, optional parameter:</p>
  
  <pre><code>public List&lt;int&gt; Wrapper(Func&lt;List&lt;int&gt;&gt; queryFunc)
  {
      var offset = 5;
      return queryFunc(offset);
  }
  </code></pre>
  
  <p>I will call the wrapper this way:</p>
  
  <pre><code>List&lt;int&gt; result = Wrapper(() =&gt; GetInts(0));
  </code></pre>
  
  <p>How can I accomplish it? How can I add parameters to a Func, when I don't know the signature of the function that the Func points to?</p>
  
  <p>In case the reason I want to do it is relevant:</p>
  
  <p>I have many functions, with different signatures, that query different db tables.
  Some of these queries' result set is too big, so I want to use (MySQL) the Limit function:</p>
  
  <p>'some mysql query' limit offset,batchsize</p>
  
  <p>And then concatenate the results at the wrapper function.
  So I added additional parameters (offset, batchsize) to some of the functions, And I want the wrapper function to added these parameters to the function that Func points at.</p>
  
  <p><strong>EDIT:</strong>
  I don't understand the reason for the down vote.</p>
  
  <p>I have multiple functions with different signatures which query my db.</p>
  
  <p>The problem is that in some cases, the result set is too big and I get a timeout exception.</p>
  
  <p>Because the result set is too big, I want to get small chunks of result sets, then concatenate them all into the complete result set.</p>
  
  <p>For example: the original result set size is 500K which causes a timeout.</p>
  
  <p>I want to get result sets sized at 1K, 500 times. </p>
  
  <p>That's why I need to control the offset from within the Wrapper, so that at each iteration, I could send the offset, which is incremented after every iteration, as a parameter to the original function.</p>