'Unable to cast object of type 'System.Int32' to type 'System.Decimal' in dot net

In My DB i have type cast the values varchar to decimal(18,2) and in my api i gave decimal datatype of output parameter then the error is getting.

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 != ''
public class GetUserBidOutPut
{
    [Key]
    public decimal? HighestBid { get; set; }
   

}
 public async Task<object> getuserbidamount(GetUserBidInPut objbidamnt)
    {
        SqlConnection conn = new SqlConnection(connectionString);
        try
        {
            _objInfoLogger.Info("Calling Store Procedure : getUserBid_sp");
            string pocfunc = "exec getUserBid_sp '" + objbidamnt.ip_ActivityId + "','" + objbidamnt.ip_Postid + "'";
            var bid = await regstContext.getuserbidamount
           .FromSqlRaw(pocfunc)
            .ToListAsync();
            conn.Close();
            return bid;
            
        }

        catch (Exception ex)
        {
            conn.Close();
            throw ex;
        }
    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
     => optionsBuilder.UseSqlServer(dbconnectionstr);
Error: Unable to cast object of type 'System.Int32' to type 'System.Decimal'.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source