Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Store 3 decimal places #1092


User avatar
0
apachon created

Hi, I want to store 3 decimal places in my db aspnetzero app but it does not allow me. When I save a record aspnetzero only keeps two (2) decimal places. Please advice an dwhich class I should to check, thanks


8 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can do it in OnModelCreating of your db context for a single property like this.

    modelBuilder.Entity<YourEntity>().Property(p => p.YourProperty).HasPrecision(18, 3);
    

    Then add necessay EF code first migration and update your database.

  • User Avatar
    0
    Hasan created

    Sorry to bother you Ismail

    I have the same issue

    My DB datatype is numeric(18,6) but when I am storing more than 2 digits. It is always getting stored only 2 digits

    Plesase check it from your end

    This is going to be massive blocker for us

    Please help us to solve this

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think your problems happens when you call a appService from client side ? If that is right, your problem is related to Json.Net I think.

    You can take a look at this issue, there is an offered solution, you can try that. <a class="postlink" href="http://stackoverflow.com/questions/17855746/webapi-json-net-and-losing-decimal-precision">http://stackoverflow.com/questions/1785 ... -precision</a>

  • User Avatar
    0
    Hasan created

    No it is not.

    It happens when i am trying to save update via UpdateAsync Method.

    Here is the image (PORTION.png). You can see the Price Column. It has 0.002 but it goes to db as 0.00.

    I have attached the Profiler Image as well (PROFILER.png)

  • User Avatar
    0
    ismcagdas created
    Support Team

    Did you also set precision for your field in OnModelCreating of your DbContext and added the migration ?

  • User Avatar
    0
    Hasan created

    Yes I have done that... Still same

  • User Avatar
    0
    Hasan created

    Could you please update me ?

    It's urgent Please

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I couldn't reproduce it. Can you share your entitiy and your onmodelcreating code? Maybe i can reproduce with your code.

    If there is something special in menuItemManager's updateAsync please share its code as well.