I have an entity with a NrPeso decimal property that can be saved in the database as 0 or null. Here is what I'm doing to assign the value to the property:
entity.NrPeso = Convert.ToDecimal(object.value("value"))
The problem is: if I don't fill the object value, it's set to Nothing
. When I do the cast it turns into 0. But I don't want 0, I want Nothing
. If I compare the object value with Nothing
it will return me Nothing
if it is Nothing or 0.
I tought in a few alternatives but they don't seem good.
So, what is the right way to do this?