SqlFunctions.StringConvert不工作双打 [英] SqlFunctions.StringConvert doesn't work with doubles

查看:304
本文介绍了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中)

这篇关于SqlFunctions.StringConvert不工作双打的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆