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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:39:02+00:00 2026-06-08T07:39:02+00:00

I have a simple List with dummy data as follows: List<Organisation> list = new

  • 0

I have a simple List with dummy data as follows:

List<Organisation> list = new List<Organisation>();
list.Add(new Organisation() { LogoUrl = "/images/logos/Blade.png", OrganisationId = 1, OrganisationName = "Blade" });
list.Add(new Organisation() { LogoUrl = "/images/logos/Torn.png", OrganisationId = 2, OrganisationName = "Torn" });

When I run the linq query:

var results = from org in OrganisationsController.GetDummyList()
              where org.OrganisationName.StartsWith(searchString)
              select org;

It always returns an Empty result. In this case the searchString is specified by the user and the example would be “Tor”.

Using different variations like ‘where org.OrganisationName == searchString‘ where the search string is Torn works. But StartsWith never works.

Any ideas where I’m going wrong?

EDIT:
From Jon’s code I changed my code to look as follows:

public JsonResult Search(string searchString)
{
    //create json result object
    JsonResult data = new JsonResult();

    var list = OrganisationsController.GetDummyList();

    //query the list
    var results = from org in list
        where org.OrganisationName.ToLower().Contains(searchString.ToLower())
        select org;

    if (results.Any())
    {
        System.Diagnostics.Debug.Write("found");
    }

    //setup the data
    data.Data = results;

    //return the data
    return Json(data, JsonRequestBehavior.AllowGet);
}

Note: I changed the StartsWith to Contains, but both are giving me similary problems.
One of my organisations is called ‘Absa’. Here’s the really strange thing when I fire up the app for the first time putting in ‘bsa’ returns nothing, I then enter ‘Absa’ and it returns a good result. Then I entered ‘bsa’ again just to double check and it returned Absa which it didn’t in the first test. Why would the result not work at first then work later?

Thanks,
Jacques

  • 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-06-08T07:39:03+00:00Added an answer on June 8, 2026 at 7:39 am

    Unable to reproduce. It works fine for me:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    class Organisation
    {
        public string LogoUrl { get; set; }
        // Removed redundant Organisation prefixes
        public int Id { get; set; }
        public string Name { get; set; }
    }
    
    class Test
    {
        static void Main()
        {
            // Used collection initializer for sanity
            var list = new List<Organisation>
            {
                new Organisation { LogoUrl = "Blade.png", Id = 1, Name = "Blade" },
                new Organisation { LogoUrl = "Torn.png", Id = 2, Name = "Torn" },
            };
    
            string searchString = "Tor";
            var query = from org in list
                        where org.Name.StartsWith(searchString)
                        select org;
    
            // Nicer version:
            // var query = list.Where(org => org.Name.StartsWith(searchString));
    
            Console.WriteLine(query.Count()); // 1
        }
    }
    

    Work out the difference between your code and my code to find out what’s wrong.

    In particular, you’ve shown code using List<T>, which means LINQ to Objects. If your real code uses LINQ to SQL or Entity Framework, that could easily affect things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple listview and listadapter setup as follows: listAdapter = new ArrayAdapter<MyDomainObject>(this,
I have a simple unordered list with 16 list items. I want to add
I have a simple list of images that is being controlled via a CMS
I want to add simple list/combo box with action script 3 . but i
I have a simple list with a listselector like so. <ListView android:id=@+id/list android:layout_width=fill_parent android:layout_height=fill_parent
I currently have a simple list view adapter that holds two rows of text.
Ok we have a simple udf that takes a XML integer list and returns
In my Android application, I have a simple list view with adapter. There's a
I have simple link list and when you hover over it it appends a
I have a simple list-type php page, which lists items according to a mysql

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.