Yes, the page property on the Generated model has 0 items, its an IEnumerable, even though the content item is linked correctly to a page
Here is an example of a method where I'm getting a content item by a particular field value, i have similar methods for getting by Id, Guid, etc.
public async Task<T> GetReusableContentItemByFieldAsync<T>(
string contentTypeName,
string field,
string value,
string localization,
int maxLevel,
CancellationToken cancellationToken = default) where T : new()
{
var builder = new ContentItemQueryBuilder()
.ForContentType(
contentTypeName,
config =>
{
config.Where(x =>
{
x.WhereEquals(field, value);
}).TopN(1);
config.WithLinkedItems(maxLevel);
})
.InLanguage(localization);
var contentItemResult = await _executor.GetResult(builder: builder,
resultSelector: container => _queryMapper.Map<T>(container),
options: new ContentQueryExecutionOptions() { ForPreview = _channelContext.IsPreview },
cancellationToken: cancellationToken);
return contentItemResult.FirstOrDefault() ?? new T();
}
Also a similar method to get the current page which is referencing CTA items which in turn reference the reusable schema
public async Task<T?> GetCurrentPageAsync<T>(
int maxLevel = ApplicationConstants.ContentDefaults.DefaultMaxLevel,
CancellationToken cancellationToken = default) where T : new()
{
var currentPage = _webPageDataContextRetriever.Retrieve().WebPage;
var builder = new ContentItemQueryBuilder()
.ForContentType(currentPage.ContentTypeName,
config => config.ForWebsite(currentPage.WebsiteChannelName)
.Where(where => where.WhereEquals(nameof(IWebPageContentQueryDataContainer.WebPageItemID), currentPage.WebPageItemID))
.WithLinkedItems(maxLevel))
.InLanguage(currentPage.LanguageName);
var pageResult = await _executor.GetWebPageResult(builder: builder,
resultSelector: container => _queryMapper.Map<T>(container),
options: new ContentQueryExecutionOptions() { ForPreview = _channelContext.IsPreview },
cancellationToken: cancellationToken);
return pageResult.FirstOrDefault() ?? default;
}
When the LinkType is File or URL then these values are populated, which makes sense as they are just strings. The Page property is always empty
This is my reusable schema
public interface IRsfhLinkFields
{
/// <summary>
/// Code name of the reusable field schema.
/// </summary>
public const string REUSABLE_FIELD_SCHEMA_NAME = "Rsfh.LinkFields";
/// <summary>
/// LinkType.
/// </summary>
public string LinkType { get; set; }
/// <summary>
/// Page.
/// </summary>
public IEnumerable<IWebPageFieldsSource> Page { get; set; }
/// <summary>
/// URL.
/// </summary>
public string URL { get; set; }
/// <summary>
/// FileItem.
/// </summary>
public IEnumerable<ContentType_File> FileItem { get; set; }
}
If I change the Page property to
public IEnumerable<PageType_Page> Page { get; set; }
then it works as expected.
I'm guessing that I'm missing something in my queries but can't work it out. I even tried Claude with the documentation MCP server