title: How can i recursively call, query filter and change an api call using linq?
body: <p>I cant post full code as its closed source, but the code would look something like this:</p>
  
  <pre><code>var total = await apiCall(arg1, queryParams(arg1, argThatNeedsToChange)).Select(e =&gt;
                 e.Where(i =&gt; i.value == value)
                  .Where(i =&gt; i =&gt; i.value == value)
                  .Where(i =&gt; i =&gt; i.value == value &amp;&amp; i =&gt; i.value2 == value2)
                  .SelectMany(i =&gt; i =&gt; i.value == value)
                  .Sum(i =&gt; (decimal) i.Amount))
                  .Select(Convert.ToUInt64); 
  </code></pre>
  
  <p>This works (when its not obfuscated), but the api call returns a set of different items, up to a max of 100. this code does not cover if there are over 100 items that match the .Where filters and will therefore have an incorrect total. what i need to do is something like:</p>
  
  <pre><code>var total = await apiCall(arg1, queryParams(arg1, argThatNeedsToChange)).Select(e =&gt;
                   While(e.Count % 1 == 0){ e.Concat(await ApiCall(args1, queryParams(args1, e[e.Count - 1].Valuexyz)))} // this should return 'e' concatenated with the results of the looped api calls.
                  .Where(i =&gt; i.value == value)
                  .Where(i =&gt; i =&gt; i.value == value)
                  .Where(i =&gt; i =&gt; i.value == value &amp;&amp; i =&gt; i.value2 == value2)
                  .SelectMany(i =&gt; i =&gt; i.value == value)
                  .Sum(i =&gt; (decimal) i.Amount))
                  .Select(Convert.ToUInt64); 
  </code></pre>
  
  <p>a property of the last object in the result of the api call, is used in subsequent api calls in order to page back through results further than 100. i need to add this to the linq to get all items that satisfy the filters, not just the top most 100.</p>
  
  <p>i should also note that the api call returns an <code>IObservable</code> using <code>RxNet</code>, so in this case im awaiting an <code>IObservable</code>, not an <code>async Task</code> function. The async function is converted to <code>IObservable</code> internally using <code>Observable.FromAsync()</code></p>