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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:01:32+00:00 2026-05-30T02:01:32+00:00

I have a silverlight app using Prism practices; the current code does a search

  • 0

I have a silverlight app using Prism practices; the current code does a search by first name or last name or gender. regaring the names, I would like to alter the code to somethng like 3 characters because now it is searching as long as one character is found the name will display so you can see the issue, can I adjust the code here to only select those with a 3 character match? lets leave alone the issue of a name with less than 3 but we can allow anything there then.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PBM.Web.Classes
{
    public class Search
    {
        public static IQueryable<Patient> GetSearchQueryPatient(IQueryable<Patient> pSearchQuery, Patient pPatient)
        {
            if (!string.IsNullOrEmpty(pPatient.FirstName))
            {
                pSearchQuery = pSearchQuery.Where(item => item.FirstName.Contains(pPatient.FirstName));
            }

            if (!string.IsNullOrEmpty(pPatient.LastName))
            {
                pSearchQuery = pSearchQuery.Where(item => item.LastName.Contains(pPatient.LastName));
            }

            if (pPatient.Gender.HasValue && pPatient.Gender.Value > 0)
            {
                pSearchQuery = pSearchQuery.Where(item => item.Gender.Value == pPatient.Gender.Value);
            }

            pSearchQuery = pSearchQuery.OrderBy(item => item.FirstName).ThenBy(item => item.LastName);

            return pSearchQuery;
        }
    }
}
  • 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-30T02:01:34+00:00Added an answer on May 30, 2026 at 2:01 am

    If I’ve read your requirement and sample code correctly, simply add a length check to your tests should work:

    if (!string.IsNullOrEmpty(pPatient.FirstName) && pPatient.FirstName.Length > 2)
    {
        pSearchQuery = pSearchQuery.Where(item => item.FirstName.Contains(pPatient.FirstName));
    }
    

    It does mean that if the name is less than 3 characters it won’t match at all, so what you want to do is then check if this search returned anything and if not do the simple any length search:

    if (!string.IsNullOrEmpty(pPatient.FirstName))
    {
        // First look for a 3 or more character match
        if (pPatient.FirstName.Length > 2)
        {
            pSearchQuery = pSearchQuery.Where(item => item.FirstName.Contains(pPatient.FirstName));
        }
        // If didn't find anything do the simple search
        if (!pSearchQuery.Any())
        {
            pSearchQuery = pSearchQuery.Where(item => item.FirstName.Contains(pPatient.FirstName));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight 4 app using Prism 2.2 and I have a few
I'm writing a Silverlight app using the MVVM pattern. I have a main view
I am developing a Silverlight app using VS2008 Express. I have just implemented a
For example: First, say I have a Silverlight app with Windowless=true so that I
I have a Silverlight 3 app using WCF RIA Services and Entity Framework for
I have a Silverlight 4 app which pulls entities down from a database using
I have a scribbale inkpresenter in my silverlight app that I'm using multiple times
I am using prism framework in a silverlight app with multiple modules in separate
I have a search textbox on silverlight app where user types in search term
I have a computationally intensive task that users can perform using a Silverlight app.

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.