是否可以在 ContentService 的钩子中将 IContent 转换为 IPublishedContent 或模型的构建器模型?
更具体地说,我正在使用 Saving 挂钩,如下所示。挂钩参考:https ://our.umbraco.com/documentation/reference/events/contentservice-events
问题是内容变量是 IContent 类型,我不能转换它。
我的相关代码将变量“问题”返回为空:
private void ContentService_Saving(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentSavingEventArgs e)
{
foreach (var content in e.SavedEntities)
{
var documentType = content.ContentType.Alias;
var question = content as IPublishedContent;
}
}