Error: The method "Int32 Parse (System. String), linqsystem. string" is not recognized by LINQ to Entities.
When an error is found during breakpoint debugging, the statement is:
public ActionResult SomeMethod(string someId)
{
var temp = SomeService.LoadEntities(a => a.ID == int.Parse(someId));
}
The reason is: data type conversion cannot be implemented within the Lambda expression.
Solution: Convert the data type before using the Lambda expression.
public ActionResult SomeMethod(string someId)
{
int tempInt = int.Parse(someId);
var temp = SomeService.LoadEntities(a => a.ID == tempInt);
}
The method "SystemString ToString ()" does not recognize linq to entity.
Your writing looks awkward. Why do you need to judge whether it is greater than or equal to 0? Your purpose is to take the ID contained in the string. So, why not use in?
Convert string to int in Linq
LINQ to Entities does not recognize the method "Int32 Parse (System. String)", so this method cannot be converted to a storage expression.