title: Convert Double to Decimal in LinQ Query
body: <p>im doing a LinQ query in C# , but im getting this error:</p>
  
  <blockquote>
    <p>An exception of type 'System.NotSupportedException' occurred in System.Data.Entity.dll but was not handled in user code</p>
    
    <p>Additional information: Casting to Decimal is not supported in LINQ to
    Entities queries, because the required precision and scale information
    cannot be inferred.</p>
  </blockquote>
  
  <p>Recently I created a RIA Services in my Lightswitch Application, and I want to get a simple operation.</p>
  
  <pre><code>public class Reporte_HorasporCliente
  {
      [Key]
      public int ID { get; set; }
      public string Cliente { get; set; }
      public double HPD { get; set; }
      public double? HPG { get; set; }
      public double? HAP { get; set; }
      public double? HCL { get; set; }
      public double? HEP { get; set; }
      public double? HEJ { get; set; }
      public double? HFT { get; set; }
      public double? HPP { get; set; }
      public double? Saldo { get; set; }
      public decimal? Cumplimiento { get; set; }
      public DateTime FechaOrden { get; set; }
  }
  
  public IQueryable&lt;Reporte_HorasporCliente&gt; getReporteHrsCliente()
      {
          var query = from q in this.Context.DetalleOrdenCompras
                      select new Reporte_HorasporCliente
                      {
                          ID = q.Id,
                          Cliente = q.OrdenCompra.Cliente.Nombre,
                          HAP = q.HAP,
                          HCL = q.HCL,
                          HEJ = q.HEJ,
                          HEP = q.HEP,
                          HFT = q.HFT,
                          HPD = q.HPD,
                          HPG = q.HPG,
                          HPP = q.HPD - q.HPG,
                          Saldo = q.HPD - q.HEJ,
                          FechaOrden = q.OrdenCompra.FechaOrden,
                          Cumplimiento = (q.HEJ == 0 ? 0 : ((q.HPD / q.HEJ) * 10) / 100),
                      };
          return query;
      }
  </code></pre>
  
  <blockquote>
    <p>HEJ and HPD are double.</p>
  </blockquote>
  
  <p>In "Cumplimiento" im doing:</p>
  
  <pre><code>Cumplimiento = (decimal)(q.HEJ == 0 ? 0 : ((q.HPD / q.HEJ) * 10) / 100),
  Cumplimiento = Convert.ToDecimal((q.HEJ == 0 ? 0 : ((q.HPD / q.HEJ) * 10) / 100)),
  Cumplimiento = (q.HEJ == 0 ? 0 : (((decimal)q.HPD / (decimal)q.HEJ) * 10) / 100),
  </code></pre>
  
  <p>Whitout any results, i really need some help, thank you.</p>