title: LINQ Sum method error
body: <p>Following <code>LINQ</code> query gives me the error shown below:</p>
  
  <p><strong>Error</strong>: </p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Double' to type 'System.Nullable'1[System.Single]'.</p>
  </blockquote>
  
  <p><strong>LINQ query</strong>:</p>
  
  <pre><code>using (gEn myEntities = new gEn)
  {
      var load = (from items in myEntities.Orders
      select items.PayO).Sum();
  }
  </code></pre>
  
  <p><strong>Model</strong>:</p>
  
  <pre><code>Public class Order
  {
      Public int OrdersId {get; set;}
      Public float? PayO {get; set;}
  }
  </code></pre>
  
  <p><strong>NOTE</strong>: </p>
  
  <ol>
  <li>The PayO column of corresponding Orders table in SQL Server 2012 is of type <code>real</code> and all its values are greater than zero (if that matters)</li>
  <li>For testing purposes, in the above query if I replace <strong>select items.PayO</strong> by, say, <code>select 2</code> the <code>LINQ</code> query works fine and returns the sum of 2 repeated as many times as the number of rows in the table. For example if table has 4 rows, the <code>LINQ</code> query will return <code>8</code> (i.e 2+2+2+2)</li>
  </ol>