New features

Glass.Mapper.Sc V3 has been around for nearly 2 years now and we have had over 26,000 downloads from Nuget which is amazing! We are now looking forward to the future and we wanted to give you an overview of the major changes that will come in V4. The new features were demonstrated at the Sitecore Users Virtual Group which you can watch below, more details about each feature can also be found further down the page.

Nuget Packages

I have long worried that there were too many Nuget packges for Glass.Mapper.Sc, for example in v3 we have the following:
  1. Glass.Mapper
  2. Glass.Mapper.Sc
  3. Glass.Mapper.Sc.CastleWindsor
  4. Glass.Mapper.Sc.Mvc-3
  5. Glass.Mapper.Sc.Mvc-4
  6. Glass.Mapper.Sc.Mvc-5

These were necessary but it could be confusing for users when trying to work out which to install. In V4 we have simplified this down to just ONE:

  1. Glass.Mapper.Sc

Glass.Mapper.Sc will contain all the core DLLs required to run Glass:

  • Glass.Mapper.dll
  • Glass.Mapper.Sc.dll
  • Glass.Mapper.Sc.Mvc.dll

To make things simpler V4 uses a Powershell script to decided which references to add to your project, it checks both the Sitecore.Kernel version and the System.Web.Mvc version and then installs the appropriate Glass.Mapper.Sc and Glass.Mapper.Sc.Mvc assembly. 


In V4 we have started to compile a version of Glass.Mapper.Sc per Sitecore version. This will give use the ability to take advantage of specific features in newer versions of Sitecore. Below is an image of the file structure you will find in the Glass.Mapper.Sc Nuget package:


You can see that we will be supporting version 7+ of Sitecore and version 3+ of ASP.NET MVC.


This project started life as a way of allowing developers to use the Razor syntax in the Sitecore solution without using MVC. The uptake in this project has been relatively low (I use it myself but only on the Glass website) and therefore to make thing simpler we have decided to no longer support the project. At some point after the start of May 2015 we will remove this project from

Castle.Windsor has been removed!

One of the biggest questions we get about Glass.Mapper and one of the large barriers to uptake is the use of Castle Windsor as an IOC container. Most developers have their preferred IOC container and didn't like having to add Windsor just to use Glass.Mapper. It was possible to swap out the Castle Windsor container for a different IOC container but this involved a lot of work by the developer.

To avoid this issue we have decided to remove Castle Windsor and replaced this with the factory pattern. This allows us to use a very simple method of constructing dependencies within Glass.Mapper.Sc. This also means that you can create your own IOC solution for Glass.Mapper by implementing one interface and managing the dependency registrations yourself. 

For those of you who were using Castle Windsor and want to continue using it we will have a Nuget package on the Glass Build server to support this.

We will be providing information on how you can upgrade your Sitecore solution from v3 to v4 in the next few weeks. 

The solution still requires the Castle.Core assembly so you will see this being included by Glass.Mapper.Sc.

Edit Frames

A great new feature is the ability to quickly and simple create Edit Frames for content on a page. Normally this is a slow process of having to create items in the Sitecore Core database with the names of the fields you want to appear in the edit frame. With V4 you will be able to create edit frames directly in your code and let Glass.Mapper.Sc do all the hard work of setting up the required elements in the Core database. 
Take for example the code below:

@using (BeginEditFrame(Model.Page, "Edit Metadata", x => x.DisplayInMenu, x => x.Closed))
This will create an Edit Frame that will allow me to edit the fields DisplayInMenu and Closed directly from my code. I don't need to create any items in Sitecore to make this work, Glass.Mapper.Sc handles that for me. If I want to add another field I simply add it onto the list of fields and Glass handles it:
@using (BeginEditFrame(Model.Page, "Edit Metadata", x => x.DisplayInMenu, x => x.Closed, x=> x.Content))
This is a massive time saver. 


We have added a new caching mechanism to the object construction pipeline to make your pages blazing fast. By default object created by Glass.Mapper.Sc won't be cached unless you explicitly state they should be:

    [SitecoreType(Cachable = true)]
    public class Slide:ISlideImage, ISlideVideo

The cache is treated in the same manner as the HTML cache and cleared when the a publish occurs using the publish:end and publish:end:remote events. 

We have designed this to be flexible to that you can add your own caching technology. To implement you simply need to implement the Glass.Mapper.Caching.ICacheManager implement and register it with the IOC container used by Glass.Mapper. This will allow you to experiment with different cache techniques, for example using Redis servers to quickly distribute cached objects across multiple servers or change how the cache is cleared to make it more targeted.

If you want to see how this performs check out our Performance Page.

MVC Improvements

No requirement for GlassView

We have extended the MVC support so that you don't have to  inheriting from Glass.Mapper.Sc.Web.Mvc.GlassView<T> when you want to take advantage of Glass Page Editor support. You will now be able to access these features more easily as a Html extension method. For example using a GlassView your CSHTML file might look like this:
@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<MyModel>

@Editable(x => x.Title)

Instead of this syntax you can simply define the model and then use the extension method:

@model MyModel

@Html.Glass().Editable(x => x.Title)

This brings Glass more into line with how most people expect MVC views to work.

Models from Views

A few months ago John West wrote a blog post about how you can determine the model you View Renderings use from the view itself instead of defining it in Sitecore. Nathanael Mann then recently made some improvements to the original code by John West and added caching to make it quicker. Nathanael has now contributed this code to the Glass.Mapper.Sc code base, this means that if you are using Glass.Mapper.Sc your life has just been made a huge amount easier and your development lifecycle even quicker!

Fluent Configuration Mapping Generics

Fluent configuration is a great way to separate your custom configuration from your POCs. It is very popular and we wanted to create a method of making it easier to register these configurations. 

The first change is that we have added a AddMaps method to the GlassMapperScCustom class that allows you to quickly register you configuration classes.

public static void AddMaps(IConfigFactory<IGlassMap> mapsConfigFactory)
     // Add maps here
      mapsConfigFactory.Add(() => new MenuItemConfig());

We have also add the SitecoreGlassMaps class that allows you  to easily create the mappings for you models:

    public class MenuItemConfig : SitecoreGlassMap<MenuItem> 
        public override void Configure()
                x => x.AutoMap(),
                x =>  x.Field(y =>  y.Display).FieldName("Display In Menu"),
                x =>  x.Delegate(y =>  y.Title).GetValue((context) =>  context.Item["Title"] + " Hello World").SetValue(), 

Performance Improvements

Further to the performance changes made during the V3 lifecycle, we have continued to focus on ensuring that performance is at its peak. This has resulted in V4 being the fastest version of Glass to date. We are very pleased with the results and I think you will be too. Find out more about how Glass compares to raw Sitecore performance using our live performance comparison.


With such a great new set of features, we firmly believe that Glass V4 will continue to be the most popular ORM in use with Sitecore. As always, we have endeavoured to listen to the feedback from all of our users and continue to improve not only the features, but your development experience based upon it. We hope you will enjoy the latest offering and continue to help us help you.
comments powered by Disqus