title: Proper Way to Retrieve More than 128 Documents with RavenDB
body: <p>I know variants of this question have been asked before (even by me), but I still don't understand a thing or two about this...</p>
  
  <p>It was my understanding that one could retrieve more documents than the 128 default setting by doing this:</p>
  
  <pre><code>session.Advanced.MaxNumberOfRequestsPerSession = int.MaxValue;
  </code></pre>
  
  <p>And I've learned that a WHERE clause should be an ExpressionTree instead of a Func, so that it's treated as Queryable instead of Enumerable. So I thought this should work:</p>
  
  <pre><code>public static List&lt;T&gt; GetObjectList&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; whereClause)
  {
      using (IDocumentSession session = GetRavenSession())
      {
          return session.Query&lt;T&gt;().Where(whereClause).ToList();                
      }
  }
  </code></pre>
  
  <p>However, that only returns 128 documents. Why?</p>
  
  <p>Note, here is the code that calls the above method:</p>
  
  <pre><code>RavenDataAccessComponent.GetObjectList&lt;Ccm&gt;(x =&gt; x.TimeStamp &gt; lastReadTime);
  </code></pre>
  
  <p>If I add Take(n), then I can get as many documents as I like. For example, this returns 200 documents:   </p>
  
  <pre><code>return session.Query&lt;T&gt;().Where(whereClause).Take(200).ToList();
  </code></pre>
  
  <p>Based on all of this, it would seem that the appropriate way to retrieve thousands of documents is to set MaxNumberOfRequestsPerSession and use Take() in the query. Is that right? If not, how <strong>should</strong> it be done?</p>
  
  <p>For my app, I need to retrieve thousands of documents (that have very little data in them). We keep these documents in memory and used as the data source for charts.</p>
  
  <p>** EDIT **</p>
  
  <p>I tried using int.MaxValue in my Take():</p>
  
  <pre><code>return session.Query&lt;T&gt;().Where(whereClause).Take(int.MaxValue).ToList();
  </code></pre>
  
  <p>And that returns 1024. Argh. How do I get more than 1024?</p>
  
  <p>** EDIT 2 - Sample document showing data **</p>
  
  <pre><code>{
    "Header_ID": 3525880,
    "Sub_ID": "120403261139",
    "TimeStamp": "2012-04-05T15:14:13.9870000",
    "Equipment_ID": "PBG11A-CCM",
    "AverageAbsorber1": "284.451",
    "AverageAbsorber2": "108.442",
    "AverageAbsorber3": "886.523",
    "AverageAbsorber4": "176.773"
  }
  </code></pre>