title: LINQ .SUM() and nullable db values
body: <p>I know why this is happening but can somebody point me in the right direction of syntax?</p>
  
  <p>Currently I have:</p>
  
  <pre><code>var expense = from e in db.I_ITEM
                where e.ExpenseId == expenseId
                select e;
  
  return expense.Sum(x =&gt; x.Mileage ?? 0);
  </code></pre>
  
  <p>My problem is that x.Mileage is of type "double?" and has null values in the db.</p>
  
  <p>The error I get is:</p>
  
  <pre><code>Exception Details: System.InvalidOperationException: The cast to value type 'Double' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.
  </code></pre>
  
  <p>What would be the correct syntax?</p>