orchardcmsorchardcms-1.6

Orchard CMS - How to access the items in a container?


It is necessary to get access to the members of the container element, how to implement it, tell me where to look. Zaklyuchaetsya essence in the following: there is a container in which to contain certain elements necessary to realize the possibility of getting the property values of these elements.


Solution

  • To copy a previous answer I've made:

    The actual content items aren't stored on ContainerPart. Instead, each contained item's CommonPart has a Container value that links to the container. You need to use LINQ to locate all ContentItems that have CommonPart.Container equal to your container.

    int containerId = containerItem.Id;
    
    var containedList = _contentManager
                .Query<CommonPart>()
                .Join<CommonPartRecord>()
                .Where(x => x.Container.Id == containerId)
                .List();