문제

I have something like that in code

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

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

any help?

도움이 되었습니까?

해결책

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"

From the STR documentation:

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

References:
SqlFunctions.StringConvert Method (Nullable)
SqlFunctions.StringConvert Method (Nullable, Nullable, Nullable)
STR (Transact-SQL)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top