This project is read-only.

Querying for Parent Record (ContentPicker related)

Topics: Customizing Orchard, Writing modules
May 19, 2016 at 3:12 PM
I have three ContentTypes:

Each of these ContentTypes has an associated part: BikePart, BikeGeometryPart, BikeConfigurationPart, and BrandPart.

A Bike can have a single Brand content item "attached" to it. I'm using a ContentPickerField on the BikePart to relate a Brand to it.

A Bike can have multiple BikeConfigurations content items "attached" to it. I'm using a ContentPickerField on the BikePart to relate 1 or more BikeConfiguration content items to my Bike content type.

A Bike can have multiple BikeGeometry records "attached" to it. I'm using a ContainerPart on the Bike Content Type to define that relationship.

I'm displaying a BikeConfiguration content item and want to show links and information to the "parent" content item, but I can't figure out how to query for the parent content item from the child content item.

Can someone provide some guidance on the best way to accomplish this?

Considering how everything is stored, it seems to best way would be to, in addition to how I relate things currently, have a "parent" field at the BikeConfigurationPartRecord, BikeGeometryPartRecord, and BrandPartRecord level that stores the parent ID. When I save a Bike Content Type, simply add some logic to update the child records as well with this information. Thoughts on this approach relative to other options?