2016-06-09 112 views
1

我不得不使用...SQL - 类型无效

的C#

public double price { get; set; } 

SQL准则

Select id, (0.0) AS price from Product 

代码,但这个代码中,我得到这个错误:

"ExceptionMessage":"The specified cast from a materialized 'System.Decimal' type to a nullable 'System.Double' type is not valid."

另外我不想改变co (c#)

+0

铸造你的sql值在C#端双倍价格=(双)dbValue' – Sherlock

回答

1

(0.0)返回一个数值类型,它是mapped为十进制。所有你需要的是投入浮动,这是映射到双,所以:

SELECT id, cast(0.0 as float) AS price from Product 

应该做的伎俩。

+0

谢谢你,它的工作原理 – ara