我有以下在Visual Studio中結構爲模板:Sitecore的玻璃映射器ObjectToSwitchTo在頁編輯器空引用
下一個頁面,我有一個或多個鏈路根
[SitecoreType(TemplateId = "{4AAA9A10-36C2-484F-A648-2BEF349F0052}", AutoMap = true)]
public class LinkRoot : IBaseTemplate
{
[SitecoreChildren(InferType = true)]
public virtual IEnumerable<LinkItem> Children { get; set; }
[SitecoreInfo(SitecoreInfoType.TemplateId)]
public virtual Guid TemplateId { get; set; }
public Guid Id { get; set; }
public string Language { get; set; }
public ItemUri Uri { get; set; }
public int Version { get; private set; }
}
下的鏈接根我「已經LinkItems
[SitecoreType(AutoMap = true)]
public class LinkItem : IBaseTemplate
{
[SitecoreField("Link Name")]
public virtual string LinkName { get; set; }
[SitecoreField("Link")]
public virtual Link Link { get; set; }
public Guid Id { get; set; }
public string Language { get; set; }
public ItemUri Uri { get; set; }
public int Version { get; private set; }
}
我在那樣的視圖中顯示這些項目:
@foreach (var link in Model.Children.Where(o => o.TemplateId.Equals(TemplateIDs.LinksRoot.Guid)))
{
foreach (var linkChildren in link.Children)
{
using (BeginRenderLink(linkChildren, x => x.Link, isEditable: true))
{
@Editable(linkChildren, x => x.LinkName)
}
}
}
它的偉大工程,我可以看到我的好名字等環節,但是當我去的網頁編輯,我得到這個錯誤:
值不能爲空。參數名稱:objectToSwitchTo
在Sitecore.Diagnostics.Assert.ArgumentNotNull(Object參數,字符串argumentName) 在Sitecore.Common.Switcher
2.Enter(TValue objectToSwitchTo) at Sitecore.Data.Items.ContextItemSwitcher..ctor(Item item) at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression
1場,Expression`1 standardOutput,T模型,對象參數,語境上下文,數據庫數據庫,TextWriter作家)
有人已經經歷過,或有一個想法,爲什麼我有這個錯誤?
謝謝
我試過了,但並沒有解決問題:< – JobiJoba