I have a Amount column in database which is in Varchar datatype, I am retrieving the data from table and I am casting for the amount should be returned as (12345.0,111.00) like this, so here I am casting with decimal, but in my ASP.NET Core the output data type is mismatching. How can I get the output like this (12345.0,111.00) from both API and database.
select max(cast(Amount as DECIMAL(18,2))) as HighestBid from Bids where PostId = @ip_Postid
and Amount != ''
select min(cast(Amount as DECIMAL(18,2))) as HighestBid from Bids where PostId = @ip_Postid
and Amount != ''
API Output :
public class GetUserBidOutPut
{
[Key]
public decimal? HighestBid { get; set; }
}
2
Answers
Use Decimal in .NET for exact numeric types with fixed decimal places, not
int
.Why are you using int and float in your Model and SQL? use DECIMAL instead.
And,