Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9210311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:02:43+00:00 2026-06-18T01:02:43+00:00

I have following code in my page: var myVar= Entity.SetName .Where(p => int.Parse(p.ID) >=

  • 0

I have following code in my page:

var myVar= Entity.SetName
                 .Where(p => int.Parse(p.ID) >= start &&
                  int.Parse(p.ID) <= end);

start and end are int, but p.ID is string. So i should convert p.ID to int. But i get following error:

LINQ to Entities does not recognize the method ‘Int32
Parse(System.String)’ method, and this method cannot be translated
into a store expression.

Where is the problem??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:02:44+00:00Added an answer on June 18, 2026 at 1:02 am

    First, I would highly recommend to check your database design, whether there is a really good reason for ID to be a string. I would consider changing the ID DB type to int and you will get rid of this problem with converting.

    The error you get means, that EF does not know how to convert the method Int32.Parse() to SQL.
    Basically you have two options how to deal with that:

    Do the comparison outside the linq to entities:

    var myVar= Entity.SetName.AsEnumerable()
                     .Where(p => int.Parse(p.ID) >= start &&
                      int.Parse(p.ID) <= end);
    

    But this is not recommended, because you are reading whole result set from DB, before applying the where condition.

    Or make custom model defined function as described in this post on SO:

    Convert String to Int in EF 4.0
    or
    Entity Framework: Where do I extend the CSDL/MSL?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in a CSHTML razor page: @{ var sort =
I have the following code on my page: $('#Report').click(Report); function Report() { var e
I have the following Code var page = '<h1>Hello!</h1><p>FOO</p><span class=username>this is ur name</span><p>sample text</p>';
I have the following code: @helper RetrievePhotoWithName(int userid) { var database = Database.Open(SC); var
I have the following jQuery code in place on my page: var isChanged =
I have the following code snippet in my page. <script type=text/javascript> function expandCollapse(id){ var
I have the following code in may page var x = parseInt($(this).css('backgroundPosition').split( )[0]); Everything
I have the following code which posts file to ASP.net page: using (var Client
i have following code to show div on page <div id=all_users> <div id=user11 userid=11
I have following code. ASPX Page <a href=AnyASPXPageOfWebsite.aspx onclick=javascript:CallJQuery(); > Set Price </a> JS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.