user1765862
user1765862

Reputation: 14145

nhibernate mapping decimal with precision and scale

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                  
);

Upvotes: 4

Views: 5335

Answers (1)

BobRock
BobRock

Reputation: 3467

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

Upvotes: 8

Related Questions