Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7862147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:00:58+00:00 2026-06-02T23:00:58+00:00

I have a case where decimal fields are being truncated to five decimal places

  • 0

I have a case where decimal fields are being truncated to five decimal places when saving to the database. This happens even though I have mapped them with a precision of 10 places after the decimal.

I’m using NHibernate 3.2.0.4000 and FluentNHibernate 1.3.0.717 with SQL Server 2008.

Here is my C# property:

public virtual decimal? MyDecimalField { get; set; }

I’ve tried doing an auto mapping override:

mapping.Map(x => x.MyDecimalField).Precision(28).Scale(10);

I’ve also tried doing explicit mapping of the field:

Map(x => x.MyDecimalField).Precision(28).Scale(10);

When doing a schema export, the table gets created correctly:

create table MyTable (
    Id UNIQUEIDENTIFIER not null,
   MyDecimalField DECIMAL(28, 10) null,
   primary key (Id)
)

Using a value of 5.1234567890, here are snippets of parameters from the generated SQL update statement:

@p31 decimal(28,5)
@p31=5.12345

I am able to make this work correctly if I use XML mapping:

<property name="Decimal01" precision="28" scale="10"/>

I have removed all conventions for decimal fields and still have the problem.

Since XML based mapping works, this leads me to believe that it is a problem with Fluent. Any suggestions on something else I may have missed?

Thanks,
Skip

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:00:59+00:00Added an answer on June 2, 2026 at 11:00 pm

    I’m going to answer my own question here. Thanks to @Firo for giving me some tips that pointed me to a solution.

    I have a convention to set the default length for my string fields:

        public void Apply(IPropertyInstance instance)
        {
            instance.Length(350);
        }
    

    But my acceptance criteria did not exclude decimal fields. I added in some acceptance criteria to exclude decimals:

        public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
        {
            criteria
                .Expect(x => x.Type != typeof(decimal) && x.Type != typeof(decimal?));
        }
    

    Doing this corrected my decimal precision.

    What’s interesting is that my default string length of 350 did not appear in my exported XML mapping files for the decimal fields. But it appears that FNH was still using it somehow. This seems like a FNH bug to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a case where I want to do this: var els = {
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200
If I want a double to have 9 decimal places, do I have to
I have a decimal value (64.17 hours) and need to convert this to a
I have a case where I want to show the marker in green color
I have a case class that has a few parameters for its constructor, and
I have a case where I databind to a date field inside model in
I have a case where I need to import an overlay map in top
I have a case i hadn't formerly, and really can't figure it out, what
I have a case where I need to combine two transparent layers on top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.