MMD MNC
MMD MNC

Reputation: 159

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

I'm using the following code :

using(var sd=new dataEntities())
{
var listofdata=sd.users.where(d=>d.id.ToString().Contain("2"));// id as int
// error : LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
}

I looked at the site but did not find answer

Upvotes: 2

Views: 4136

Answers (1)

Noel
Noel

Reputation: 600

You need to use the SQL Function to translate the ToString method.

SqlFunctions.StringConvert((double)id)

Answered Here: Problem with converting int to string in Linq to entities

Upvotes: 7

Related Questions