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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:03:56+00:00 2026-05-26T00:03:56+00:00

I am working on ASP.net MVC 3.0 Razor View Engine Application. I have a

  • 0

I am working on ASP.net MVC 3.0 Razor View Engine Application.
I have a Advance Search form to get the list of Customers found
Which will have fields like

  • FirstName TextBox
  • LastName TextBox
  • DOB TextBox
  • Address TextBox
  • Gender DropDown
  • Zipcode TextBox
  • Ignore Address checkBox
  • Finally the Submit Button.
    I have a list of Customers in a List object.
    No field is Mandatory in the Search Form.
    When User hits search based on the Values he provided in the Form,
    my Logic should return the matching results from the List Object that is holding all Customer details.

    So I would like to pick an idea from you.
    to write a best logic that will find the Customer based on user provided info.

    I started with something like this

    if (fname != "" && lname == "")
            {
                return _CustomerList.FindAll(p => p.FirstName == fname);
            }
            else if (fname == "" && lname != "")
            {
                return _CustomerList.FindAll(p => p.LastName == lname);
            }
    
            else if (fname != "" && lname != "")
            {
                return _CustomerList.FindAll(p => p.FirstName == fname && p.LastName == lname);
            }
    return _CustomerList;
    

    I don’t think this is an efficient way.

    Any advises would be a great help.
    thank you for reading. 🙂

    • 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-26T00:03:57+00:00Added an answer on May 26, 2026 at 12:03 am

      Use Linq instead and an IEnumerable<Customer> – you can compose your query with additional Where() clauses as needed and at the end return the matching items as list using ToList().

      var matchingCustomers = _CustomerList;
      
      if (!string.IsNullOrEmpty(lname))
      {
          matchingCustomers = matchingCustomers.Where(x => x.LastName == lname);
      }
      
      if (!string.IsNullOrEmpty(fname))
      {
          matchingCustomers = matchingCustomers.Where(x => x.FirstName == fname);
      }
      
      //...
      
      return matchingCustomers.ToList();
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I am working on asp.net MVC 3 application. I have created a Razor view
    I am working in ASP.NET MVC 3 application, I am using razor view. I
    I have a working ASP.NET MVC web application to manage projects and customers. Now
    i am working in asp.net mvc 3 web application which uses razor code. and
    Working on an ASP.NET MVC 3 (Razor) application, that's mainly concerned with UGC (user
    VS2010 Ultimate, ASP.NET MVC 3 w/Razor. I've created a custom view engine in my
    I'm working with ASP.Net MVC 3 with the Razor engine and version 9.104.0.20 of
    I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
    I've a following asp.net mvc razor view code which doesn't seem to be working:
    asp.net mvc 3 with razor I have a script inside a partial view <script

    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.