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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:36:12+00:00 2026-05-23T20:36:12+00:00

I am implementing a search where I would like to partially match an entity’s

  • 0

I am implementing a search where I would like to partially match an entity’s primary key. For example, if I would search for “123” it would return entities which have primary keys like:

  • 12345
  • 67123
  • 91234

If this were a string, I’d attack it like this:

    public PartialViewResult QuickSearch(string searchTerm)
    {
        var results = db.MyEntities.Where(x => x.myProperty.Contains(searchTerm));
        return PartialView("QuickSearch_Results", results);
    }

However I’m at a loss on the best way to do this for an int. I’m looking for something like this:

    public PartialViewResult QuickSearch(int id)
    {
        var results = db.MyEntities.Where(x => x.myPropertyId.Contains(int));
        return PartialView("QuickSearch_Results", results);
    }

But obviously contains is not the right way to go. What would be a correct way of implementing this?

  • 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-23T20:36:13+00:00Added an answer on May 23, 2026 at 8:36 pm

    Totally wild and untested guess using the StringConvert method:

    public PartialViewResult QuickSearch(int id)
    {
        string sId = id.ToString();
        var results = 
            from x in db.MyEntities
            where SqlFunctions.StringConvert((double)x.myPropertyId)
                              .Contains(sId)
            select x;
        return PartialView("QuickSearch_Results", results);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a search in my website, and would like to support searching for
I'm currently implementing a search form in our users database. I would like to
I am implementing a search module with result page support paging. The example provided
I'm implementing global search box extension (sth like SearchableDictionary sample in android sdk). Everything
I would like to implement a fast search on an ArrayList of objects. These
I am implementing an eCommerce application using ASP.Net. I would like to know if
I'm implementing a face tracker on Android, and as a literature study, would like
I am implementing real-time searching of a UITableView. I would like to display the
I would like to implement a m-way search tree and i need the basics
In implementing faceted search, if the number of options is 7 or less, I

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.