嗨,我正在使用 glassmapper,我正在尝试读取多列表中的所有项目并进行填充。
我的页面有一个导航、标题和一个多列表字段,我可以在其中选择项目。我的问题是,虽然我能够读取子项目(计数 > 0),但属性值为空。但是Sitecore的基本Item属性不为空Fieldtype并没有解决问题这是我的两个Model
public class Pagebase: ItemBase, INavigation
{
//Page Base
public string PageTitle { get; set; }
public string PageHeading { get; set; }
//Navigation
public string NavigationTitle { get; set; }
public string NavigationDescription { get; set; }
public IEnumerable<Pagebase> SubItems{ get; set; }
}
[SitecoreType(TemplateId = "{7BC902B5-305B-484A-9AD9-6AAEBA48BDD7}", AutoMap = true)]
public interface INavigation
{
[SitecoreField("Navigation Title")]
string NavigationTitle { get; set; }
[SitecoreField("Navigation Description")]
stringNavigationDescription { get; set; }
[SitecoreField("Sub Items")]
IEnumerable<Pagebase> SubItems{ get; set; }
}
我的观点是这样的
@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<xxx.Pagebase>
<div class-"test">
@Model.NavigationTitle // This has value
@Model.NavigationDescription // This has correct value
@Model.SubItems.Count // Show the correct number of Items selected in Multi list.
// The multilist is again a Pagebase type.
//When i do :
@foreach (var subItem in Model.SubItems)
{
@subItem.NavigationTitle //This is null
@subItem.NavigationDescription // This is null
@@subitem.Id / @subitem.Url / @subitem.Name / // This is not null
}
</div>
我错过了什么??