Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nhibernate mapping decimal with precision and scale

Tags:

c#

nhibernate

inside db I have field which is decimal(9, 6)

Nhibernate save this data with losing last digit in format decimal(9, 5)

Question is how to map field using nhib. mapping by code to use precision 9,6

Property(
   x=>x.Longitude
   // precision and scale                  
);
like image 788
user1765862 Avatar asked Feb 17 '23 04:02

user1765862


1 Answers

you can set explicitly to this type precision and scale like this

Property(
    x => x.Longitude,
    m =>
        {
            m.Precision(9);
            m.Scale(6);
        }
 );

or you can set in conventions to match all decimals in your app, this is outside of this question (just an idea).

Hope this helps

like image 52
BobRock Avatar answered Feb 27 '23 16:02

BobRock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!