【发布时间】:2018-02-16 10:56:48
【问题描述】:
我们正在实施不同的 Umbraco 服务,使用 ApplicationContext 从 Umbraco 后端提取数据。在调用服务方法本身时,它总是返回 null 或给出“Nullable object must have value”的异常。 这可能是因为 umbracoNode 表中的 nodeUser 列中的 NULL。如果我在数据库中更新 0,我的服务运行良好。但如果我在 umbraco 后端执行保存,它会再次将 nodeUser 设置为 NULL。
这是我的代码:
var contentService = ApplicationContext.Current.Services.ContentService;
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var contentType = contentTypeService.GetContentType("blog");
var contents = contentService.GetContentOfContentType(contentType.Id);
谁能帮我摆脱困境?
【问题讨论】:
-
您能否提供一个更完整的引发/返回错误的代码示例?仅这 4 行不足以获得有关问题的任何上下文,也不太可能成为问题的根源。
UserId字段在设计上可以为空,因此如果您正在访问它并假设它不为空,这可能会导致您的问题。 -
var contentType = contentTypeService.GetContentType("blog");这是线路抛出/返回错误。
标签: service nodes umbraco nullable