Tim Jarvis
Tim Jarvis

Reputation: 18815

Embedded RavenDb Query on Index

I am playing around with RavenDb I have a very simple class that contains a collection, I am trying to return all the objects where the contained collection has more than 1 record, cannot seem to make it work.

Note: I am using an In-Memory Embedded document store in LinqPad, reading some data from a RDBMS and inserting into the In-Memory store (this works, if I just Query<Agency>().Take(100) I see my records...

enter image description here

Any Idea's ?

below image just to show that the db does contain my data...

enter image description here

Upvotes: 1

Views: 145

Answers (1)

Tim Jarvis
Tim Jarvis

Reputation: 18815

ok, I have figured it out, can't say I fully understand it...but...

PopulateRavenInMemory();
DatabaseCommands.PutIndex("MultipleAddresses",  
    new IndexDefinitionBuilder<Agency>
{
    Map = agencies => from a in agencies
                    where a.Addresses.Count() > 1
                    select new {}
});
Query<Agency>("MultipleAddresses").Customize(x => x.WaitForNonStaleResultsAsOfNow()).Dump();

I understand the WaitForNonStaleResults call, that makes sense, but I don't really understand why my Map function cannot select the class, it seems to demand a projection, I can move on, but I hate not knowing why this is so.

Upvotes: 1

Related Questions