title: Why does a Func<T,bool> work with RavenDB query if I have 4k documents, but not when I have 800k documents?
body: <p>If I have 4 thousand documents (maybe quite a few more, haven't checked) I can use a <code>Func&lt;T,bool&gt;</code> in <code>IDocumentSession.Query&lt;T&gt;().Where(...)</code> and I get the expected results. But if I have 800 thousand documents then I have to use an <code>Expression&lt;Func&lt;T,bool&gt;&gt;</code>, otherwise I get no results.</p>
  
  <p>Why is this not consistent?</p>
  
  <p>The issue is that I have the same predicate used for an in-memory filter as well as a database query filter. For the in-memory filter the collection is <code>IEnumerable&lt;T&gt;</code> so it uses a <code>Func&lt;T,bool&gt;</code> whereas for the database query the collection is an <code>IQueryable&lt;T&gt;</code> so it uses an <code>Expression&lt;Func&lt;T,bool&gt;&gt;</code>. So in my production code I have an overloaded "filter" method - one that takes an <code>IEnumerable&lt;T&gt;</code> and another that takes an <code>IQueryable&lt;T&gt;</code>. Content of the former is: <code>return list.Where(getPredicate(x).Compile())</code> and content of the latter is: <code>return list.Where(getPredicate(x))</code></p>
  
  <p>Obviously this just looks like duplicated code and is shouting out: "Please refactor me and reduce the code duplication". But as soon as a developer does that it should break a unit test. However, I can't get a unit test to fail when passing a <code>Func&lt;T,bool&gt;</code>.</p>
  
  <p><strong>Edit:</strong> Upon closer inspection, it appears that it has nothing to do with the number of documents. If I connect to the same "production" database in my unit test (calling the actual production code), it returns results when using <code>Func&lt;T,bool&gt;</code> but when I run the application it returns nothing. Very strange!</p>