Error: the method of not recognizing the LINQ to Entities & ldquo; Int32 Parse (System. String), linqsystem. string

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.