title: How to handle null value in entity framework sum function
body: <p><a href="https://i.stack.imgur.com/LRdzf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LRdzf.png" alt="Screenshot"></a> </p>
  
  <p>My code is here:</p>
  
  <pre><code>Int64? amount = db.Items.Where(x =&gt; x.ItemOrdered == true).Sum(x =&gt; x.Price);
  </code></pre>
  
  <p>That work fine but through Error database is empty</p>
  
  <blockquote>
    <p>The cast to value type <strong><code>'System.Int32'</code></strong> failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.</p>
  </blockquote>
  
  <p>I want replace it with 0 (zero)<br>
  I am using entity frame work with MVC application</p>