title: "Nullable object must have a value" when Where uses a method?
body: <p>I'm trying to run a LINQ query against an Azure DocumentDB collection. When I run my query I keep getting an <code>AggregateException</code> that contains an <code>InvalidOperationException</code> with the message:</p>
  
  <blockquote>
    <p>Nullable object must have a value</p>
  </blockquote>
  
  <p>I've reduced this issue to the following (somewhat contrived) example:</p>
  
  <p>When I run this code, I get the above mentioned exception thrown from the call to <code>ToArray()</code></p>
  
  <pre><code>public class MyDocument { ... }
  
  public void RunQuery()
  {
      var query = documentDbClient
          .CreateDocumentQuery&lt;MyDocument&gt;()
          .Where(doc =&gt; GetDoc(doc) != null);
      var results = query.ToArray()
  }
  
  public MyDocument GetDoc(MyDocument myDocument)
  {
      return myDocument;
  }
  </code></pre>
  
  <p>In contrast, when I run the code below no exception is thrown and I get back good results from the DocumentDB collection.</p>
  
  <pre><code>public void RunQuery()
  {
      var query = documentDbClient
          .CreateDocumentQuery&lt;MyDocument&gt;()
          .Where(doc =&gt; doc != null);
      var results = query.ToArray()
  }
  </code></pre>
  
  <p><strong>Why the difference in behavior between the two code samples?</strong></p>
  
  <p>Notes:<br>
  - While <code>GetDoc()</code> is a stand in for my more complex predicate logic, the code above reproduces the issue <em>exactly</em>. I'm not withholding any shenanigans inside <code>GetDoc()</code> or other methods :)<br>
  - The issue occurs even when <code>GetDoc()</code> is made <code>static</code>.<br>
  - Just tried to reproduce with a <code>List&lt;MyDocument&gt;</code> instead of  <code>documentDbClient</code> and no exception was thrown. Indicates something in the underlying data provider = Azure DocumentDB's <code>IDatabaseClient</code>.</p>