Filtering on a related object property
I'm trying to improve some bits of our application. I have a relationship between content that looks like this:
A Group has many Lists has many Events.
Group, List and Event are all content items with a corresponding part record for each type with links. Currently to find all events in a group I use HQL to find the ids then pull these using GetMany. This works fine, I'm just wondering if I can make a query like this work:
var videoQuery = _contentManager .Query(VersionOptions.Published) .Join<EventContainablePartRecord>() .Where(x => x.EventListPartRecord.EventGroupPartRecord.Id == 13) .List();
This query fails, it cant find EventGroupPartRecord property. Is there a way I can expand the linked property somehow? I've had a quick google but cant find any examples and I tried QueryHints but they don't seem to be what I'm looking for. It is interesting how the queries are translated because it is possible to reference an object's Id like this:
var lists = _contentManager .Query(VersionOptions.Published) .Join<EventListPartRecord>() .Where(x => x.EventGroupPartRecord.Id == group.Id) .List()
You can only access the Id property of EventGroupPartRecord, no other properties.
I had a look at taxonomies, they have queries that reference collections within an object. I can make queries like that too.
var test = _contentManager.Query<EventGroupPart, EventGroupPartRecord>() .Where(e => e.EventListParts.Any(b => b.Events.Any(t => t.Id == 12))).List();
This query works. Does nHibernate know to build subqueries for these collections? So I can traverse the relationship from the top entity but not from the bottom entity?