Language Fallback has always been a little tricky when using Glass.Mapper.Sc because it was necessary to use the VersionCountDisabler欧美人与禽交片mp4 class. This was required because Glass.Mapper checks the number of version of an item in the requested language and returns null if there are no versions. The VersionCountDisabled stops this check from happening and returns a model using the empty Item that Sitecore returns allowing you to map shared fields to the model.

This has changed in Sitecore 8.1, the new now mean that you no longer need to use the VersionCountDisabler.

For example lets take the following code running in Sitecore 8.1:

        protected void Page_Load(object sender, EventArgs e)
            var sitecoreContext = new SitecoreContext();
            using (new VersionCountDisabler())
                Model1 = sitecoreContext.GetCurrentItem<Model>();

            Model2 = sitecoreContext.GetCurrentItem<Model>();


In the watch window we can see that both the code in the VersionCountDisabler and outside return a Model:

欧美人与禽交片mp4We can also see in the watch window that the original language was english (the fallback language) and the requested language was Italian:

欧美人与禽交片mp4This is great news because now your Glass.Mapper solutions can become even simpler!

Glass needs your support!

欧美人与禽交片mp4 Glass.Mappper.Sc is supported by the generous donations of the Glass.Mapper.Sc community! Their donations help fund the time, effort and hosting for the project.

These supporters are AMAZING and a huge thank you to all of you. You can find our list of supporters on the Rockstars page.

If you use Glass.Mapper.Sc and find it useful please consider supporting the project. Not only will you help the project but you could also get a discount on the Glass.Mapper.Sc training and join the Rockstars page.

Become a Rockstar