3

Environment: Sitecore 9.0.2 + Glass Mapper

I have a class like this:

public class Sample
{
    public Glass.Mapper.Sc.Fields.Image Logo { get; set; }

    public string Destination_Name { get; set; }
    public bool Is_Atttraction { get; set; }

    public string ID { get; set; }

    public Glass.Mapper.Sc.Fields.Link Explore_More_Link { get; set; }

    public ProductCardViewModel productCardViewModel { get; set; }
}

The component loads properly on the website. Inside the experience editor, it breaks and I have a message like below:

Failed item resolve - You cannot save a class that does not contain a property that represents the item ID. Ensure that at least one property has been marked to contain the Sitecore ID. Type: **NameOfMyClass**

Any inputs will be helpful.

1 Answer 1

5

You want to change your ID property to type Guid. Also, you can add the attribute SitecoreId to the property.

[SitecoreId]
public Guid ID { get; set; }

This should allow Glass to map to your class properly. You can see a really basic example of this on the Glass Mapper website: http://glass.lu/Mapper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.