querying collections inside collections

15 views
Skip to first unread message

Chanan

unread,
Sep 21, 2011, 4:46:45 PM9/21/11
to ravendb
I am trying to run a query like:

from m in Session.Query<Movement>()
from l in m.Locations
select new MapLocationViewModel { Name = m.Name, Latitude =
l.Latitude, Longitude = l.Longitude };

However I am getting: Method not supported: SelectMany

What would be the correct way to create a query like that?

Itamar Syn-Hershko

unread,
Sep 21, 2011, 5:36:01 PM9/21/11
to rav...@googlegroups.com
Is this the complete index?

and what build are you using? we fixed something that may be related in the recent unstables, if you can try that.

Itamar Syn-Hershko

unread,
Sep 21, 2011, 5:36:30 PM9/21/11
to rav...@googlegroups.com
Sorry, misread your code

Can you provide a failing test?

Chris Marisic

unread,
Sep 21, 2011, 5:49:34 PM9/21/11
to rav...@googlegroups.com
Chanan, this question seems to directly parallel my question Projection query not behaving as expected . I did find a method that works, however I'm not certain it's the optimal solution. I am looking forward to some feedback on it.

Ayende Rahien

unread,
Sep 22, 2011, 1:21:48 AM9/22/11
to rav...@googlegroups.com
Chanan,
You can't do that in a query. You can do that as an index and then query that.
What exactly are you trying to do?

On Wed, Sep 21, 2011 at 11:46 PM, Chanan <cha...@gmail.com> wrote:

Chanan

unread,
Sep 22, 2011, 8:23:58 AM9/22/11
to ravendb
Hi Ayende & Chris,

Using build 465.

I tried to create it as an index, but I don't think I have it quite
right.

Lets say I have a person with a few properties like name and a
property which is a collection of addresses.

I would like to output:
Oren Business Tel Aviv
Oren Home Ramat Gan
Chanan Home Hampton
Chanan Business Clark
Joe Home Tel Aviv

And of course query it so I can take only the one from Tel Aviv.

So I thought my query would be:

from p in Session.Query<Person>()
from l in m.Locations
select new MapLocationViewModel { Name = p.Name, Type=
l.type, Town= l.Town};

That gives me the error I said above (SelectMany). I also tried it as
an index, but I get back the person object, which is not what I
wanted. I am guessing it might have to do with Live Projections option
of the index?

Ayende Rahien

unread,
Sep 22, 2011, 8:31:09 AM9/22/11
to rav...@googlegroups.com
Chanan,
Can you show this with a test?

Chanan

unread,
Sep 22, 2011, 11:06:22 AM9/22/11
to ravendb
Hi Ayende,

You want the test that gives me the exception of the SelectMany?

On Sep 22, 8:31 am, Ayende Rahien <aye...@ayende.com> wrote:
> Chanan,

Ayende Rahien

unread,
Sep 22, 2011, 1:00:37 PM9/22/11
to rav...@googlegroups.com
Check the other thread, I sent a passing test there
Reply all
Reply to author
Forward
0 new messages