I'm new in dotNet development and trying to create an API with response having decimals. I'm expecting that the API will show 0.000000
but instead only shows 0
.
This is the data from my database
public class InvAmt
{
public double buyWsAmount { get; set; }
public double buyRetAmount { get; set; }
public double sellWsAmount { get; set; }
public double sellRetAmount { get; set; }
}
[HttpGet]
public async Task<ActionResult<List<InvAmt>>> GetInvAmt()
{
var connString = _config.GetConnectionString("Mysqlconn");
using (IDbConnection conn = new MySqlConnection(connString))
{
string sql = $@"SELECT pa.buy_ws_amount AS buyWsAmount, pa.buy_retail_amount AS buyRetAmount, pa.sell_ws_amount AS sellWsAmount, pa.sell_retail_amount AS sellRetAmount FROM product_amount pa;";
var res = await conn.QueryAsync<ProductCategory>(sql, null);
return res.ToList();
}
}
API response
[
{
"id": 1
"buyWsAmount": 1300,
"buyRetAmount": 26,
"sellWsAmount": 1800,
"sellRetAmount": 36.000001,
},
{
"id": 52
"buyWsAmount": 0,
"buyRetAmount": 0,
"sellWsAmount": 0,
"sellRetAmount": 0,
}
]