ComponentOne LiveLinq > How to Use LiveLinq > Using Indexes Programmatically |
Indexes are used by LiveLinq to optimize query execution, but they are also accessible for programmatic use. You can use indexes directly in code, calling methods of the Index<T> class to perform a variety of fast searches. This makes LiveLinq indexes useful even outside the framework of LINQ, outside queries.
For example, searching for a particular value can look like this:
indexByCity.Find("London")
or even like this:
indexByCity.FindStartingWith("L")
The Index<T> class also has other methods for performing fast searches and fast joins and groupings that can be useful in any code, not just in queries: FindGreater, FindBetween, Join, GroupJoin, and a few others.
Examples of programmatic searches (without LINQ) can be found in the LiveLinq indexing demo, see Query Performance sample application (LiveLinqQueries). In fact, every query that is shown in that demo has an alternative implementation via direct programmatic search in code without LINQ.