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

SO this is my code so far: JS: <script type=text/javascript> function Hide(srcField) { var
This is my code so far: var n = 123456789; var d = n.toString().length;
I'd like to Join a List and a DataRowCollection , my Code so far
I'm so new to Python that the only way I can code so far
My code so far: // The q constant of the Glicko system. var q
Here's my page code so far: @model TennisClub.Models.ClubMember @{ ViewBag.Title = Details; } <h2>
This is my code so far: using System; using System.Collections; using System.Linq; using System.Text;
This is my old code: var destinctList = HoldingsList.DistinctBy(x => new { x.ClientName, x.ProductName
This is my code thus far: ArrayList<String> matches = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String playString =
I have this code so far which perfectly but relies on there being a

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.