LINQ to Entities does not recognize the method ‘System.String ToString()’ method

If you use the entity framework from microsoft, latest version at the date of this post is framework 4.0
You might run into this little angel when you try to envoke the string value of an object

LINQ to Entities does not recognize the method ‘System.String ToString()’ method

This happens when applying a filter to an integer field and you want to use the

method of a string. So my code looked ike this

From the master query

etc…

The only way i Could get round this was to onvert the UID field into a string in the master select query like so

notice the cure was to force linq to convert the resulting field into a string, allowing the filter to look like this

Microsoft have a list os supported methods here

Leave a Reply

Your email address will not be published. Required fields are marked *