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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:34:12+00:00 2026-06-18T20:34:12+00:00

How can I make a query using Entity Framework and LINQ on a alphanumeric

  • 0

How can I make a query using Entity Framework and LINQ on a alphanumeric comparison only? I have a database table with an AccountNumber field which contains special characters, so an example account number might look like this: 803-2234502-345. But the account number that I’m given to search by will not have the special characters: 8032234502345

    string accountNumber = "8032234502345";
    Provider provider = dbContext.Providers.Where(p => p.AccountNumber == accountNumber).FirstOrDefault();

I’ve tried adding a Regex.Replace to both sides of the comparison, but I get an exception:

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

Any help or suggestions are appreciated.

  • 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-18T20:34:13+00:00Added an answer on June 18, 2026 at 8:34 pm

    You are using Linq to Entities so can only use what functions map through to SQL in the enities mappers. You could either change the functions you are using to map properly to SQL (though I suspect with Regex you won’t be-able to do that – would have to be a more manual comparison), or (as @Dabblernl mentioned in the comments) load your Providers (or a subset of providers) into a list / or enumerable, and then run the regex over that.

    So something like:

    Provider provider = dbContext.Providers.Where(p => p != null && p != "").ToList()
    .Where(p => *Do regex comparison here*).FirstOrDefault();
    

    Possible mappings to SQL are here: http://msdn.microsoft.com/en-us/library/bb738681.aspx

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

Sidebar

Related Questions

I am using Entity Framework and perform a query on a database that returns
Who can help me make the following query work... Both tables have the fields
How can I make a mysql dump for table from a query? I need
I am trying to make a query to an SQL database and I can't
I'm having trouble building an Entity Framework LINQ query whose select clause contains method
I have an issue about Entity Framework 4 CTP 5, which I realize LINQ
I query-ing this from entity framework using WCF, and i want to use the
I've several services using Entity Framework to save many changes in a DataBase. When
I'm in VS2008 with Entity Framework. I'm accessing objects from the database using esql
I'm trying to move a project over to using Entity Framework, but to make

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.