Querying using multi-Column index

Mar 15, 2011 at 6:57 PM

Let's say this is my esent table structure

Id guid
Category string
.. other stuff ..
Created datetime 

At table creation I created an index on +Category-Created, because I want to be able to query for a specific Category (non-unique) and have them sorted by Created in descending order. I can't seem to query using that index when only specifying a search key for Category. If I change the index to just +Category, it works but they're not necessarily in descending order by Created. Is what I'm trying possible using a single multi-column Index or do I need two separate indexes, one +Category and one -Created, and intersect them?

Mar 16, 2011 at 4:18 PM

You can do exactly what you want with a multi-column index. There are a couple of things that might help. First, look at the "How Do I Make a Multi-Column Key" section of the "How Do I?" documentation:


(The "How Do I Create an Index Range?" part should be useful too)

Second, look at the DumpByNamePrefix method in the sample app. You aren't searching for a prefix so you won't need MakeKeyGrbit.SubStrLimit.