<brad-oyler/>

11
December

Querying Abstract Multi-Map Indexes in RavenDB (C#)

So… let’s say you have 2 similar classes in your system, like User & Person.

Now lets say we’d like to return those documents into a single list. In order to do this you simply need to define the “AbstractMultiMapIndex”, like so:

I call it the People index, (because Users are people too!)

After we’ve done that we need to create that index, like so (on App_Start):

 IndexCreation.CreateIndexes(typeof(PeopleIndex).Assembly, ds);

Now… all that’s left is creating an Action like so:

All this does, is execute the query on the index and return the results to the View (with a dynamic ViewBag)

Enjoy!

See last post on Initializing RavenDB with StructureMap