1

I am missing a scale (see example image below). Even though I specified the precision and scale in my dynamic parameter, I am still loosing the last non zero value.

Not sure what I missed out to do.

const string insertSql = @"insert into DATATABLE (FEES_VALUE) VALUES (@DataValue)";
var doubleValue = 0.06930846118065210000;
var parameters = new DynamicParameters();
parameters.Add("DataValue", doubleValue, dbType: DbType.Decimal, precision: 28, scale: 20);

using (var conn = new SqlConnection(connectionstring))
{
    var data = conn.Execute(query, parameters, commandType: CommandType.Text, commandTimeout: 600);
}

Example

UPDATE: Apparently, it was not a Dapper issue. It was the data type that I used. Below are the results after I tested in more detail (Thanks Cameron for suggesting)

as decimal 0.00058235001858449700
as double 0.00058235001858450000

dantz
  • 37
  • 1
  • 9
  • 1
    This is interesting because `0.06930846118065210000` can be represented exactly as a double. However, if you choose to pass it as a decimal instead (`0.06930846118065210000m`), does this affect the result? – Cameron Jun 03 '20 at 01:18
  • 1
    Thanks for bringing that out Cameron. I tested your point and found out that it is not a Dapper issue. It was the data type as decimal 0.00058235001858449700 as double 0.00058235001858450000 – dantz Jun 03 '20 at 23:46

1 Answers1

0

Changing the data type to decimal instead of double solved my problem

dantz
  • 37
  • 1
  • 9