SqlFunctions.StringConvert不工作双打

问题描述:

我在code类的东西。

I have something like that in code

SqlFunctions.StringConvert( (double?) x.Latitude)

但它总是返回一个整数,尽管它有一个纬度值。

but it returns an integer always although it has a latitude value.

任何帮助吗?

SqlFunctions.StringConvert(双?)返回一个整数转换成字符串。要返回一个十进制值,您需要提供其他的过载 SqlFunctions.StringConvert(双vaue,诠释长度,诠释小数?)如下:

SqlFunctions.StringConvert(double?) returns an integer converted to string. To return a decimal value, you need to provide the other overload SqlFunctions.StringConvert(double? vaue, int length, int decimals) as follows:

SqlFunctions.StringConvert( (double?) x.Latitude, 20, 5)

// If x.Latitude = 34.75, then the result will be "34.75000"

从STR文档:

数量默认四舍五入到整数或如果小数点
  参数为0。

The number is rounded to an integer by default or if the decimal parameter is 0.

参考文献:

SqlFunctions.StringConvert方法(可空)

SqlFunctions.StringConvert方法(可空,空,可空)

STR(Transact-SQL中)