In the implementation using Glass Mapper 4.3.x, I was enabling Lazy Loading in GlassMapperScCustom:

public static IDependencyResolver CreateResolver(){
            var config = new Glass.Mapper.Sc.Config();

            config.EnableLazyLoadingForCachableModels = true;

            var dependencyResolver = new DependencyResolver(config);

            var factory = dependencyResolver.ObjectConstructionFactory as AbstractConfigFactory<AbstractObjectConstructionTask>;

            return dependencyResolver;

This hid some recursive model references and sloppy model properties. I am looking for an easy way to re-enable before doing a large re-factorization.

Is this possible in Glass Mapper v5?


1 Answer 1


In version 5 config.EnableLazyLoadingForCachableModels setting was removed and "IsLazy"-setting was removed from all model property configuration, like

[SitecoreChildren(IsLazy = false)]
IEnumerable<ISitecoreItem> Children{get;set;}

You should just remove all these settings from your models, because of in V5 lazy loading was improved (it is enabled by default and disabled when request or model is cachable) and your model cann`t be a mix of lazy and non-lazy parts.

In version 5 you can force disable/enable lazy loading only when you retrieve your model, like

var data = _mvcContext.GetDataSourceItem<IData>(x => x.LazyDisabled());


var data = _sitecoreService.GetItem<IData>(Constants.Data.ID, x => x.LazyEnabled());

Almost all glassmapper interfaces has this parameter.

But I think that for your case it will be enough just to remove old settings when you upgrade to version 5 (at least there were no troubles on our project).

These links may be helpful:



  • Thanks. This is a case of, "Don't fight it, just rewrite it." I have been working on removing recursive model properties and data expensive model properties. Its a few days worth of work but no getting around it. Feb 8, 2019 at 13:42
  • Thank you. Can I use more than one such methods at the same time? For instance if I want LazyDisabled, but also InferType()? Aug 27, 2019 at 19:12

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.