Sitecore Glass Mapper ObjectToSwitchTo页面编辑器中的null引用 [英] Sitecore Glass Mapper ObjectToSwitchTo null reference in page editor

查看:120
本文介绍了Sitecore Glass Mapper ObjectToSwitchTo页面编辑器中的null引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中,我的模板结构如下:

I have the following structure as Template in visual studio :

在页面下,我有一个或多个链接根

Under a page, i have one or more link root

[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

Under the link root i've 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; }
}

我在这样的视图中显示这些项目:

I display those items in a view like that :

 @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)
            }
        }
    }

效果很好,我可以看到带有好名字的链接等,但是当我转到页面编辑器时,出现此错误:

It works great, i can see my links with the good name etc, but when i go to the page editor i got this error :

值不能为null.参数名称:objectToSwitchTo

Value cannot be null. Parameter name: objectToSwitchTo

在Sitecore.Diagnostics.Assert.ArgumentNotNull(对象参数,字符串argumentsName) 在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模型,对象参数,Context上下文,数据库数据库,TextWriter writer)

at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) at Sitecore.Common.Switcher2.Enter(TValue objectToSwitchTo) at Sitecore.Data.Items.ContextItemSwitcher..ctor(Item item) at Glass.Mapper.Sc.GlassHtml.MakeEditable[T](Expression1 field, Expression`1 standardOutput, T model, Object parameters, Context context, Database database, TextWriter writer)

有人已经经历过或者知道为什么我有这个错误吗?

Does someone already experienced that or have an idea why i have this error ?

谢谢

推荐答案

我认为这可能是一个错误,是否可以将它作为问题登录到github.

I think this might be a bug, can you log it on github as an issue.

这篇关于Sitecore Glass Mapper ObjectToSwitchTo页面编辑器中的null引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆