title: LINQ Max extension method gives an error on empty collections
body: <p>I have the following query:</p>
  
  <pre><code>var maxNumber = dbContext.Where(a =&gt; a.Id == 9).Max(a =&gt; a.Sample_Num);
  </code></pre>
  
  <p>If there is no Id of 9, I get an error. I like to default the result to 0 if there is no Id of 9.</p>
  
  <p>I tried:</p>
  
  <pre><code>var maxNumber = dbContext.Where(a =&gt; a.Id == 9).Max(a =&gt; a.Sample_Num) ?? 0; 
  </code></pre>
  
  <p>as well as other variations but was not able to get it to work</p>