Posts

Showing posts with the label Glass Mapper

Lazy Loading in Glass Mapper

Image
Lazy loading is on-demand loading, when users request the content by Lazy loading then instead of loading the whole content on your page it loads only required content, till further request by users. Disable Lazy Loading in Glass Mapper: Individual Get-Item Method All Sitecore Service Methods Individual Get-Item Method: In Sitecore Service Method: var item = _service.GetItem<ICustomModel>("/sitecore/content/Home/Course", x=>x.LazyDisabled()); In MVC Context method: var item = _mvcContext.GetDataSourceItem<ICustomModel>(new GetKnownOptions { Lazy = Glass.Mapper.LazyLoading.Disabled}); All Sitecore Service Methods:  If you don't want to pass x.LazyDisabled() in all the GetItem methods then prefer the Generic Class approach. Create a Generic Class as below: public class RenderingRepository : IRenderingRepository { private readonly IMvcContext _mvcContext; public RenderingRepository(IMvcContext mvcContext) ...