2

I have upgraded the website to Sitecore 9.0.2 and since my project has a dependency on Glass mapper, I have upgraded Glass mapper to 5.3.15.

My Glass mapper maps to the menu model and it does load the parent menu items but second level menu and third level menu are broken now. When I debug the code I found out that it is not able to convert the Model from IGlassBase to the ISubMenu Model. I know lazy loading of the item has been disabled by default on glass mapper.

I have tried config.EnableLazyLoadingForCachableModels = true; to see if there is any caching issue going on but it did not resolve the issue and I am still getting the same issue.

Any Idea of how to enable conversion from glass object to custom object?

  • Can you include the code for your models and how you are using/converting them? – Dan Sinclair Mar 12 at 17:31
  • I am not converting them into any thing, Its the base class i am trying to use when i regenerate the code items from Item templates.This used to wiork in previous versions of Glas mapper(4.5) – eric gonzalez Mar 13 at 3:23
  • Can you include the code for those models (the base class and the class you're trying to cast it to) as well as the code you use to retrieve the item and cast it? Obviously something's not quite right; having more context will help others help you. – Dan Sinclair Mar 13 at 11:09
2

In the upgraded version of Glass Mapper (5.3.15), I think by default it will perform mapping of all the models from IGlassBase interface during the application start. Looks like it is not performing the mapping on start up.

Glass Mapper provides API to perform this mapping on demand that should convert the base glass model to corresponding template model. Add the following API in to make sure it maps to the corresponding model in your case Navigation menu.

config.OnDemandMappingEnabled = true;

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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