Search code examples
c#.netsdkkentico-kontent

Auto Populate Linked Items in Content Item in Kentico Cloud


I have two content items. One is a doctors profile and the other content item is doctors specialty. In the doctor's profile, I link the specialty content item (Linked Item) into the doctor's profile.

So let's Say Dr. Giedrimas has a "Family Medicine" specialty.

doctor content item

Now what I would like is when I look at the Specialty content item "Family Medicine" Dr. Giedrimas should show up as a doctor that the Specialty "Family Medicine" is used in. Now I do see this on the right side of the "Family Medicine Specialty" under the header but I cannot access that list.

family medidine content item

It would be nice to just use the KC SDK to retrieve the content item "Family Medicine" and display "Used In" doctors instead of retrieving all the doctors list and filter each one for "Family Medicine" since It would be more efficient to just retrieve the "Family Medicine" specialty data instead filtering through all the doctors. Anybody have any thoughts on this or perhaps it is possible?

This question is a migrated from official Kentico Cloud Forum, that would be deleted.


Solution

  • Assuming you use using .NET SDK. To get doctors with the "Family Medicine" specialty, just use the ContainsFilter implementation for filtering:

    var response = await DeliveryClient.GetItemsAsync<DoctorsProfile>(
      new ContainsFilter("elements.specialty", "family_medicine")
    );
    

    This will use the native filtering capabilities, without the need to fetch unnecessary data into your app's memory.