Entity Framework converts int to string

entity-framework

Question

In Link to EF, how do you translate an int to a string?

The Entity Framework and the CLR are unable to determine what SQL snippet should be translated when converting an int to a string..ToString() into.

In order to return a string rather than an int, how do you create a linq statement?

1
29
10/2/2013 12:18:33 PM

Accepted Answer

Unfortunately, EF is unable to convert..ToString() . SqlFunctions, an embedded function, must be used. Zzz-8-Zzz to StringConvert Additionally, because int has no overload, you must typecast it to double: (

var vendors = 
   from v in Vendors  
   select new
   {             
       Code = SqlFunctions.StringConvert((double)v.VendorId)
   }; 
50
2/18/2017 1:06:08 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow