With the Related data API, you can optimize performance when retrieving related data items for a specific collection of items. You do this by setting this collection to the context and thus, after the first related item is requested, Sitefinity CMS loads all the related data items per property for this collection. After this initial request, each time there is an additional request from the API for the related data items, Sitefinity CMS returns the results for the items from the context and not from the provider using the following method:
void SetRelatedDataSourceContext(this IEnumerable<IDataItem> items).
To do this, use the following template:
In the following example, you have a content type Sessions and you want to retrieve all Speaker related data items for this content type. In the example, the collection retrieves the Speaker related data items per the Session title field as soon as the first Session item from the collection requests its related data items.
The following code snippet demonstrates how to use the template for retrieving the related data items for the Sessions example, described above:
For a detailed tutorial about utilizing the Related data custom field, see Tutorial: Create DevReach site with related data feature.
Back To Top
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.