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


I am using Linq to Entity to get a list of products.LINQ to Entities does not allow to use ToString() method. I am getting this error

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.

edit | flag
Mad Maddy
Asked on: Jan 18, 2012 at 5:16AM

1 Answers


This is because ToString() is turned into a MethodGroup and then parsed and translated to SQL. Since there is no ToString() equivalent this is not executed and fails.

Try parsing before the linq query and use the parsed variable in linq query


string str = Product.Name.ToString();// parsing

var list= from u in dbcontext.Orders
where u.Productname == str select u;
edit | flag
Gokul A
Answered on: Feb 08, 2012 at 9:14PM

Post your Answer


Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags