1

As Title, I can't find how to get a component object in richtext without using a strong type.

DeliveryItemListingResponse listingResponse = await kentontClient.GetItemsAsync(
     new InFilter("system.type", "property")
);

foreach(var item in listingResponse.Items)
{
     var spec = item.GetLinkedItems("d3cb9f23_7684_0174_0b8d_6320bb61cc62");
}

It throws an exception. The component d3cb9f23_7684_0174_0b8d_6320bb61cc62 object exists in a private member _linkedItemsSource. I'm guessing that GetLinkedItems searches just under its elements only.

Are there any way we can get it?

Ref: https://github.com/Kentico/kontent-delivery-sdk-net/wiki/String-based-rendering-of-items-in-Rich-text

rocky
  • 7,506
  • 3
  • 33
  • 48
fei wong
  • 11
  • 1

1 Answers1

0

Yes, absolutely.

The GetLinkedItems expects the codename of the element which contains linked items. -> Not the codename of a specific linked item. (Though, such method would probably be handy. You can request it by submitting an issue in the repo: https://github.com/Kentico/kontent-delivery-sdk-net/issues)

What you want to do is:

var linkeditems = item.GetLinkedItems("element_codename");
var yourDesiredLinkedItem = linkeditems.Where(i => i.System.Codename == "d3cb9f23_7684_0174_0b8d_6320bb61cc62");
rocky
  • 7,506
  • 3
  • 33
  • 48