Re: Searching List<T>, how to make it faster

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Is this DB populated?

I suggest you need to revist your design. Your best bet would be to populate
your list based on a DB query with a parameter called name.

Select * from Table where Name like 'x%'

alternatively you could try linq or the entity framework.





"M.H." <mh@xxxxxxxxx> wrote in message
news:%23MEVW243JHA.1864@xxxxxxxxxxxxxxxxxxxxxxx
I have List<T> with about 6000-7000 objects.
I need to select all objects that the property Name starts with
SearchText.

This is the code

foreach (T item in myList)
if (item.Name.StartsWith(SearchText))
myResults.Add(item);

It takes about 5-6 seconds and my users are not happy with the speed.

How to improve it?
I tried "for (int.." but the result was the same.

Thanks

MH


.



Relevant Pages

  • Re: create a new table from a table
    ... Description field to the second table, and populate it with the description ... confusing when you look at your database. ... with data, open that table in design view, and add the Variable_Description ... Create a new select Query containing both tables, ...
    (comp.databases.ms-access)
  • Re: Xilinx 3E design programs fine with 500E but fails with 250E
    ... Ive got a design that uses the spartan XC3S500E, but when I populate ... it fails to program the external M25P80 SPI flash ... Maybe the loading of the JTAG bus is different. ...
    (comp.arch.fpga)
  • Re: Dtabase desing and data entry
    ... You will need to create a query for the record source of your form that will ... to select the codes necessary to populate the fields in your query. ... As another design thought, you can use the Not In List events of the combos ...
    (microsoft.public.access.formscoding)
  • Re: SHAPE Command
    ... Microsoft MVP ... Please reply only to the newsgroup so that others can benefit. ... > I have two tables that are designed as follows ... > What I want to do is to populate a TreeView control with Job as the top ...
    (microsoft.public.data.ado)
  • Re: Validation Rule Violations
    ... Do any of the fields in the target table disallow Null values? ... Yes in design view). ... FROM TotalEarnings LEFT JOIN Agent ON TotalEarnings.= ... would populate at least SOME of the data, but I can't get anything to ...
    (microsoft.public.access.queries)