Left join for record

Topics: Customizing Orchard, Writing modules
Jul 21, 2011 at 5:42 PM

Hi all,

please consider the following case: record R1 (maintains part P1) has a reference to the record R2 (which maintains part P2). Parts P1 and P2 are doesn't contribute the same content type.
So, when I make a call contentManager.Query<P1, R1>().List(), this enumerates all content items that hold part P1. The issue is - records of type R2 are not included into the query, they are fetched each in a separate SQL statement, this is not good for me.
Is there any way to say the content manager to include referenced records into the query?

Thanks in advance!

Jul 21, 2011 at 6:22 PM

There is a Join method on the Query object.

Jul 21, 2011 at 6:37 PM

Yes, I know. I forgot to mention that using Join method does not correct the situation - in this case no data returned at all. Possibly I'm wrong, but this seems to be a consequence of that fact that P1 and P2 do not form the same content type.

Jul 21, 2011 at 7:48 PM

Ah, yes. We actually have some newer code that is doing this kind of join more properly, that we are very probably going to ship with the 1.3 release (a small release that fixes a few performance-related issues of that kind). In the meantime, another thing you can try that should alleviate things a little is the second-level cache module that came out recently.

Jul 21, 2011 at 8:06 PM

I haven't put that module in the gallery yet, as I was waiting for a response from Louis (or anyone) on how to override something (http://orchard.codeplex.com/discussions/263612).  Care to give it a look Bertrand?  I think this would be super helpful to people.

Jul 21, 2011 at 11:06 PM

I will have to summon the dev gods for that.