Search code examples
glass-mapper

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


We are using a repository to get Sitecore items from Solr and then map them to a Sitecore object using SitecoreContext.Map. Everything gets data except the Image property which is null.

The model is generate from TDS and the property is:

[SitecoreField(I_Base_Content_ItemConstants.ImageFieldName)] Glass.Mapper.Sc.Fields.Image Image {get; set;}

We are doing nothing custom.

Getting data from solr Mapping using SitecoreContext.Map Image property on our generated TDS class is Null

Thanks

Charlie


Solution

  • If you are using a TDS generated class make sure that you have this property on it:

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

    Glass needs this to link the Solr item to the Sitecore item.