How do you convert an int to a string in Link to EF?
The clr cant imagine casting an int to a string and Entity framework cant figure out what SQL snippet to translate .ToString()
into.
So how do you write a linq statement that returns a string instead of an int?
Sadly EF does not know how to convert .ToString()
. You must use the embedded function SqlFunctions.StringConvert: http://msdn.microsoft.com/en-us/library/dd466292.aspx Also there is no overload for int so you must typecast to double :-(
var vendors = from v in Vendors select new { Code = SqlFunctions.StringConvert((double)v.VendorId) };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With