I think I understand that you want a list of all Component Presentations using that certain Schema from the Broker, you could use the following code sample for that:
StringBuilder sb = new StringBuilder();
string templateUri = "tcm:1-7-32";
int publicationId = 1;
int schemaId = 5;
using (ComponentPresentationAssembler cpa = new ComponentPresentationAssembler("tcm:0-0-0", Page))
using (ComponentPresentationFactory cpf = new ComponentPresentationFactory(publicationId))
{
Criteria itemTypeCriteria = new ItemTypeCriteria(16);
Criteria schemaCriteria = new ItemSchemaCriteria(schemaId);
AndCriteria criteria = new AndCriteria(itemTypeCriteria, schemaCriteria);
Query query = new Query(criteria);
foreach (string uri in query.ExecuteQuery())
{
using (ComponentPresentation cp = cpf.GetComponentPresentation(uri, templateUri))
{
if (cp != null)
{
// use ComponentPresentationAssembler since cp.Content does not resolve REL
sb.Append(cpa.GetContent(string.Format("tcm:{0}-{1}",
publicationId,
cp.ComponentId),
string.Format("tcm:{0}-{1}-32",
publicationId,
cp.ComponentTemplateId)));
}
}
}
}
This sample is getting a list of all Components in the Broker based on your Schema and then get the Component Presentations available for those. Depending on your requirements, you could perhaps use cp.Content
instead of using the ComponentPresentationAssembler
, but this should give you a general idea of how to query the Broker.