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

  • Home
  • SEARCH
  • 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 7023591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:43:49+00:00 2026-05-27T23:43:49+00:00

I have a method where by I’m able to search in a database for

  • 0

I have a method where by I’m able to search in a database for a specific customer(s). At the moment it only takes 1 term, but i’d like to be able to search with multiple terms (for example the customer’s account number and their name). Below is my method:

public List<AXCustomer> allCustomers(string id)
{
    string[] searchstring = id.Split(' ');
    List<AXCustomer> customer = new List<AXCustomer>();

    // if 3 terms are entered
    if (searchstring.Length > 2)
    {

    }
    // if 2 terms are entered
    else if (searchstring.Length > 1)
    {

    }
    // revert back to default search
    else
    {
        customer = context.AXCustomers.Where(x => x.ACCOUNTNUM.Contains(id) ||
                   x.NAME.Contains(id) || x.ZIPCODE.Contains(id)).ToList();
    }

    return customer;
}

As you can see, i’ve decided to split each term entered (I assume each term will be seperated by a space) but I’m not sure how my LINQ query should be for terms longer than one. Any help would be 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-05-27T23:43:50+00:00Added an answer on May 27, 2026 at 11:43 pm

    Since you don’t know what will be entered or how long it will be, I would suggest doing the following:

    public List<AXCustomer> allCustomers(string id)
    {
        string[] searchstring = id.Split(' ');
        List<List<AXCustomer>> customerlists = new List<List<AXCustomer>>();
    
    
        foreach (string word in searchstring)
        {
            customerlists.Add(context.AXCustomers.Where(x => x.ACCOUNTNUM.Contains(word) || x.NAME.Contains(word) || x.ZIPCODE.Contains(word)).ToList());
        }
    
        //Then you just need to see if you want ANY matches or COMPLETE matches.
        //Throw your results together in a List<AXCustomer> and return it.
    
    
        return mycombinedlist;
    }
    
    • Any matches = throw all lists together, then take the distinct ones.
    • Complete matches = you’ll have to check for items which occur in all customerlists.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have method in a class that I need to make sure is only
I have a method which takes params object[] such as: void Foo(params object[] items)
I have a method that takes an IQueryable. Is there a LINQ query that
I have method for converting array of Booleans to integer. It looks like this
I have method (which is part of IMyInteface) like this: interface IMyInterface { void
I have method look like doSomething( Class<T> valueType) i call pass value like Map.class,
In mechanize, we have : method : set_cookiejar() But, why do we need a
Is it possible to have method have methods that are only callable externally and
I have method to covert character to haxa like private static String convert(char str)
I have method in my BLL that interacts with the database and retrieves data

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.