我在内容树中有子项,如下所示,必须显示在同一页面中。我们为页面创建了一个类型为ModelA
的Stronglytyped视图:
public class ModelA
{
public IEnumerable<ModelA > item1 { get; set; }
public IEnumerable<ModelB> item2{ get; set; }
}
内容树是:
Item1(Based on Template A and Created ModelA to access)
---Children11(Based on Template A and Created ModelA to access))
---Children12(Based on Template A and Created ModelA to access))
Item2(Based on Template A and Created ModelA to access))
---Children21(Based on Template B and Created ModelB to access))
---Children22(Based on Template B and Created ModelB to access))
我们使用GlassMapper来获取数据,因此我们为Children11
、Children12
定义了ModelA
,为Children21
、Children22
定义了ModelB
。
我可以为item1
获得孩子,但不能为item2
获得孩子,因为它是null
。是因为玻璃映射器无法找到它们并映射类型为ModelB
吗?
我认为您必须在属性上使用SitecoreChildren属性才能使其工作。。。