title: How to convert from decimal to double in Linq to Entity
body: <p>Suppose we have table T which has two columns A and B with float and money types respectively. I want to write a linq query like following T-SQL statement:</p>
  
  <pre><code>Select A, B, A * B as C 
  From SomeTable
  Where C &lt; 1000
  </code></pre>
  
  <p>I tried to cast like following</p>
  
  <pre><code>var list = (from row in model.Table 
              where ((decimal)row.A) * row.B &lt; 1000 
              select new { A = row.A,
                           B = row.B ,
                           C = ((decimal)row.A) * row.B}
             ).ToList();
  </code></pre>
  
  <p>but it does not allow the cast operation. It throw an exception: </p>
  
  <blockquote>
    <p>Casting to Decimal is not supported in Linq to Entity queries, because
    the required precision and scale information cannot be inferred.</p>
  </blockquote>
  
  <p>My question is how to convert double to decimal in Linq? I don't want to fetch data from database.<br/>
  <strong>Update:</strong><br/>
  I notice the converting decimal to double works but reverse operation throws the exception. So,<br/>
  Why can't we convert double to decimal? Does Sql server do the same mechanism in t-sql too? Doesn't it affect precision?</p>