首页 > 解决方案 > I get the error when using get property value on Umbraco v8

问题描述

I use Umbraco v8 and code is here

var home = Model.Root();
var results = home.Children.FirstOrDefault(i => i.IsDocumentType("results"));
var resultSliders = (results?.GetProperty("resultSliders")?.GetValue() as IEnumerable<IPublishedContent>) ?? new List<IPublishedContent>();

error message is

Object reference not set to an instance of an object.

but the results content is not empty and GetProperty("resultSliders").HasValue() return is true so I have no idea why it is giving error results?.GetProperty("resultSliders")?.GetValue(). resultSliders Property is custom nested content data type

标签: umbraco8

解决方案


推荐阅读