JSON 响应不包含特定 class 的嵌套内容
JSON response does not include the Nested content for a particular class
我正在使用 KenticoCloud DeliveryClient 与 Kentico Cloud 合作。
问题是我正在为包含 BodyContent 的 NewsArticle 加载数据。 BodyContent 有一些应该由解析器解析的 InlineContentItemData。
我添加了 PartnerList(包含多个 Partner 项目的项目)、Carousel(包含多个 ImageGridItem 项目的项目)和一些 HTML 文本。
这是发出请求的代码:
var response = await Client.GetItemsAsync<NewsArticle>(
new EqualsFilter("system.type", "news_article"),
new OrderParameter("elements.date", SortOrder.Descending)
);
(就是获取完整的文章列表,然后我们稍后找到想要的文章。我知道我可以使用 Url Slug 来检索内容,但我需要完整列表来获取其他东西)
问题是,在 JSON 响应中,有 Carousel 和 PartnerList 项目,它们都包含我从 CMS 添加的项目,但单个 Carousel 项目 (ImageGridItem) 没有出现在JSON,仅限合作伙伴项目。
谢谢
此行为可能有多种原因。我假设您也在使用 String based rendering of items in Rich text and code first approach so that you should have the ICodeFirstTypeProvider implementation defined and the resolvers。
可能的解决方案:
- 检查代码名称是否在您的
ICodeFirstTypeProvider
实现中正确定义,指向 Partner
class。
- 您也可以尝试使用数据的
DepthParameter
to force deeper loading,但不太可能解决问题,因为检索到的是各个 Carousel 项目并且它们处于相同的深度级别。
如果任何假设有误,请告诉我。如果您愿意为您正在加载的所有内容类型共享 ICodeFirstTypeProvider
的实现和 IInlineContentItemsResolver
的实现。
如果您想直接从您的项目调试 SDK 并自行查找原因,可以 use the SourceLink。
我正在使用 KenticoCloud DeliveryClient 与 Kentico Cloud 合作。 问题是我正在为包含 BodyContent 的 NewsArticle 加载数据。 BodyContent 有一些应该由解析器解析的 InlineContentItemData。 我添加了 PartnerList(包含多个 Partner 项目的项目)、Carousel(包含多个 ImageGridItem 项目的项目)和一些 HTML 文本。
这是发出请求的代码:
var response = await Client.GetItemsAsync<NewsArticle>(
new EqualsFilter("system.type", "news_article"),
new OrderParameter("elements.date", SortOrder.Descending)
);
(就是获取完整的文章列表,然后我们稍后找到想要的文章。我知道我可以使用 Url Slug 来检索内容,但我需要完整列表来获取其他东西)
问题是,在 JSON 响应中,有 Carousel 和 PartnerList 项目,它们都包含我从 CMS 添加的项目,但单个 Carousel 项目 (ImageGridItem) 没有出现在JSON,仅限合作伙伴项目。
谢谢
此行为可能有多种原因。我假设您也在使用 String based rendering of items in Rich text and code first approach so that you should have the ICodeFirstTypeProvider implementation defined and the resolvers。
可能的解决方案:
- 检查代码名称是否在您的
ICodeFirstTypeProvider
实现中正确定义,指向Partner
class。 - 您也可以尝试使用数据的
DepthParameter
to force deeper loading,但不太可能解决问题,因为检索到的是各个 Carousel 项目并且它们处于相同的深度级别。
如果任何假设有误,请告诉我。如果您愿意为您正在加载的所有内容类型共享 ICodeFirstTypeProvider
的实现和 IInlineContentItemsResolver
的实现。
如果您想直接从您的项目调试 SDK 并自行查找原因,可以 use the SourceLink。