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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:31:19+00:00 2026-05-24T04:31:19+00:00

My code so far: List<SearchEntity> results = new List<SearchEntity>(); var title = tbTitle.Text; var

  • 0

My code so far:

List<SearchEntity> results = new List<SearchEntity>();
var title = tbTitle.Text;
var adress = tbAdress.Text;
var city = tbCity.Text;

foreach (var item in list.Items.Cast<SPListItem>().Where(r => title.Contains(r.Title) || adress.Contains((string)r["Adress"]) || city.Contains((string)r["City"])))
{
    var result = new SearchEntity
                     {
                         title = item.Title,
                         adress = (string)item["Adress"],
                         city = (string)item["City"],
                     };
    results.Add(result);
}

return results;

I have tried casting all the values .ToLower() and .ToUpper() but that didn’t seem to do the trick.

  • 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-24T04:31:20+00:00Added an answer on May 24, 2026 at 4:31 am

    Method String.Contains performs case-sensitive and culture-insensitive comparison, so if you want case-insensitive contain use IndexOf method like

    title.IndexOf(r.Title, StringComparison.InvariantCultureIgnoreCase) >= 0
    

    but in your code you fetch all items and filter record there, if List will contain many items, this way is not recommended, as it involves getting all items from list. Maybe it’s better use CAML Query (or LINQ in Sharepoint2010). What do you want to find? Items where fields Title/City/Address contain value from vars title/city/address or you want find items where fields Title/City/Address value contained in vars title/city/address. In 1st case your CAML will be like:

    List<SearchEntity> results = new List<SearchEntity>();
    var title = tbTitle.Text;
    var adress = tbAdress.Text;
    var city = tbCity.Text;
    var query = new SPQuery()
    {
        Query = string.Format(
            @"
                        <Where>
                            <Or>
                                <Or>
                                    <Contains>
                                        <FieldRef Name=""Title"" />
                                        <Value Type=""Text"">{0}</Value>
                                    </Contains>
                                    <Contains>
                                        <FieldRef Name=""Adress"" />
                                        <Value Type=""Text"">{1}</Value>
                                    </Contains>
                                </Or>
                                <Contains>
                                    <FieldRef Name=""City"" />
                                    <Value Type=""Text"">{2}</Value>
                                </Contains>
                            </Or>
                        </Where>", title, adress, city)
    };
    var items = list.GetItems(query);
    foreach (var item in items)
    {
        var result = new SearchEntity
        {
            title = item.Title,
            adress = (string)item["Adress"],
            city = (string)item["City"],
        };
        results.Add(result);
    }
    return results;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code and preview: <html> <head> <title>Testing some CSS</title> <style type=text/css> .dDay { font-size:205% }
I'd like to Join a List and a DataRowCollection , my Code so far
So far i have got the code below which works lovely when trying an
So far I've been using public void run() {} methods to execute my code
I've been reading code complete, not far in yet but one of the things
According to what I have found so far, I can use the following code:
I decided to try http://www.screwturn.eu/ wiki as a code snippet storage utility. So far
We have a very important application, but so far no source code. The application
Code: <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Unusual Array Lengths!</title> <script type=text/javascript> var arrayList = new Array();
I have a string that is args[0] . Here is my code so far:

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.