5

This code:

  ContentDeliveryService cds = new ContentDeliveryService(...);
  Page itemPage = cds.Pages.Where(page => page.ItemId == itemId).Single();

Returns a page with zero ComponentPresentations (even though I know it has two). Somehow, I need to do something like:

   cds.ComponentPresentations.Expand("ComponentPresentations");

so that the returned Page will have its ComponentPresentations field populated.

What is the right syntax for this?

Thanks for your help....

1 Answer 1

3

Do something like this

var cp = (from item in service.ComponentPresentations.Expand("Component") select item)
           .AsEnumerable()
           .Where(item => item.Component.Title == "YOUR COMPONENT TITLE")
           .FirstOrDefault();
1
  • Forgive me, perhaps I'm missing something, but I don't see how that code sample helps. In my case, I do not know the "item.Component.Title", because I do not know the identity of the component(s) belonging to the page. Given that I know nothing about the component presentations belonging to a page, how do I find them? It seems like this is supposed to work by accessing the Page.ComponentPresentations field, but in these OData API's is it always null. What is the workaround, how can I find the ComponentPresentations that belong to a Page, when I know nothing about the ComponentPresentations? Commented Jul 1, 2013 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.