How to map REAL Datatype in SQL with Decimal? in C#

263 Views Asked by At

I have written a stored procedure which returns one of the value as REAL datatype since it is referring to some old database table.

I want to convert/map this value to a decimal? type in C#. However, I get an error:

Specified cast not valid

when running this code:

item.SludgeCapacity =v.Field<decimal?>("SludgeCapacity");

Does anyone have an optimised solution?

1

There are 1 best solutions below

0
On

try

item.SludgeCapacity = Convert.ToDecimal(v.Field("SludgeCapacity"));