Invalid cast with dapper and decimal(10,2)

c# dapper sql-server-2008

Question

The following code give me invalid cast operation. The Qty column in my MS Sql server is of type decimal(10,2)

#region SQL Syntax

var sql = "select qty from productarticle where articleid=@articleid and productid=@productid";

#endregion

using (IDbConnection cn = Connection)
{
    cn.Open();

    return cn.Query<double>(sql, new { articleid = articleid, productid = productid }).Single();
}

If I try to return it as int, there is no problem. Any clue?

Popular Answer



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why