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?

3
  • Can you include the code for your models and how you are using/converting them? Mar 12, 2019 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) Mar 13, 2019 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. Mar 13, 2019 at 11:09

1 Answer 1

3

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

1

Your Answer

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

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