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 6248089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:59:35+00:00 2026-05-24T12:59:35+00:00

I have the code myEntities db = new myEntities(); var query = from s

  • 0

I have the code

    myEntities db = new myEntities();
    var query = from s in db.mytable select s;
    if (!String.IsNullOrEmpty(str))
    {
      query = query.Where(p => p.total == str);
    }

Here, the type of “total” is a string containing numbers and characters, e.g. “14x56xz”. I want to get the number part (e.g. 1456) from the “total” string and convert it to a decimal number, sometimes with the need to turn it into a negative number, making the code look like this:

    query = query.Where(10 <= p => p.total <= 1000);

I have written a class to process it, but I don’t know how to invoke this processing method in Linq.

  • 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-05-24T12:59:36+00:00Added an answer on May 24, 2026 at 12:59 pm

    Just parse it in the lambda. For example:

    query = query.Where(10 <= p => decimal.Parse(p.total) <= 1000m);
    

    Of course, if there’s any way you can improve your data model so that logically-numeric values are stored as numbers, that would be even better…

    EDIT: I think you’ll have a hard time converting “14x56xz” to 1456 in LINQ to Entities. You may be able to do something at the database side to expose a computed column using conversions and regular expressions etc, but I’m not sure that you’d be able to express that in LINQ in a way which will be converted appropriately.

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

Sidebar

Related Questions

I have code like this: var newMsg = new Msg { Var1 = var1,
I have code similar to the following. using (MyEntities context = new MyEntities()) {
I have code similar to this filtering entries in an Array of Objects: var
I have code similar to the following in many places: var dbParams = db.ReadParams(memberID,
I'm trying to use Entity Framework to query database and I have following code
I have the following code that downloads an object from a 3rd party and
I have a basic LINQ Query that looks like the following: var results =
I have code that references a web service, and I'd like the address of
I have code to create another row (div with inputs) on a button click.
I have code like this: template <typename T, typename U> struct MyStruct { T

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.