使用 SitecoreContext.Map 时,GlassMapper 不映射和图像 属性(结果);

GlassMapper does not map and Image property when using SitecoreContext.Map(result);

我们正在使用存储库从 Solr 获取 Sitecore 项目,然后使用 SitecoreContext.Map 将它们映射到 Sitecore 对象。除了 Image 属性 为 null.

之外的所有内容都获取数据

模型是从 TDS 生成的,属性 是:

[SitecoreField(I_Base_Content_ItemConstants.ImageFieldName)] Glass.Mapper.Sc.Fields.Image 图片{get;设置;}

我们没有做任何定制。

从 solr 获取数据 使用 SitecoreContext.Map 映射 我们生成的 TDS class 上的图像 属性 为 Null

谢谢

查理

如果您使用的是生成的 TDS class,请确保您有此 属性:

        [TypeConverter(typeof(IndexFieldItemUriValueConverter))]
        [XmlIgnore]
        [IndexField("_uniqueid")]
        public virtual ItemUri Uri { get; set; }

Glass 需要这个才能 link Solr 项目到 Sitecore 项目。

Mike 原来是因为我们在调用 map 方法时发现 id 属性 是空的。我们通过从 sitecore 获取价值来解决这个问题并且它有效:)。谢谢。