locked
EDMX Decimal causing data issue RRS feed

  • Question

  • User1858009984 posted

    I am having real datatype in Sql and when generated edmx the datatype is decimal for that column and when i enter the value like 12.3 its saving in DB as 12.xxxxxxxx. How to store exactly what user enters. The issue is while assigning to edmx datatype only.

    Wednesday, September 13, 2017 2:28 AM

All replies

  • User753101303 posted

    Hi,

    A database is just storing values and doesn't care about formatting. It just happens that values are always *shown* according to some convention. For decimal columns, SQL Server Management Studio shows all decimal places (ie you likely have something such as 12.300000)

    Your web app should show the value without non significant 0 digits (ie 12.3 assuming your web app is configured for a country which uses . rather than some other symbol for the decimal point).

    In short you have to make the difference between the actual value (ie 12.3 is 12.3 every on earth) and how it is shown (12.3 12,3 12.30000 is just 3 ways to show the same value depending on which convention is used).

    Wednesday, September 13, 2017 7:57 AM
  • User-1768369891 posted

    How to store exactly what user enters.

    If you want to enter exactly as user enter then you can used varchar instead of real, but when you getting back you must need conversion varchar to double/float. 

    Wednesday, September 13, 2017 8:16 AM
  • User-707554951 posted

    Hi Ravindranath M,

    From your description, you have real datatype in Sql but when generated edmx, the datatype is decimal.

    However, I test it and when generated edmx, the datatype is float.

    The output as below:

    in edmx.

    I suggest that you could set the datatype as float in sql dataase to store what user enters.

    For more detail, you could refer to the following link:

    https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings

    https://stackoverflow.com/questions/1056323/difference-between-numeric-float-and-decimal-in-sql-server

    Best regards

    Cathy

    Thursday, September 14, 2017 9:21 AM