SqlFunctions.StringConvert doesn't work with doubles
asp.net, c#, entity-framework, linq, sql-function
Solution
`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)
Problem
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?