Casting to Decimal is not supported in LINQ to Entities queries

前端 未结 4 1679
后悔当初
后悔当初 2021-02-14 01:58

I have a database table Transaction (transactionID, LocalAmount...). where datatype for Localamount property is float. ON the UI I am trying to return a

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-14 02:38

    If you don't happen to have the luxury of calling AsEnumerable than you can convert it to int and than to decimal with some math.

     (((decimal)((int)(x.Discount * 10000))) / 10000)
    

    Each zero actually represents the precision that the conversion is going to have.

    Got this answer from this. Just take a look at the end of the file.

提交回复
热议问题