Working with Sitecore, Part Ten: Glass Sitecore Mapper

Wednesday, March 27, 2013 @ 03:36

By: Josh Jenkins, Lead Consultant


Glass Sitecore Mapper is an object mapping framework for mapping Sitecore items directly onto an object model, this allows you to model your entire Sitecore solution in code. The framework handles reading and writing to fields, creating relationships (parent, child, etc) and much more. The second aim of the project is to make your Sitecore code unit testable by letting you deal with simple .NET classes that you create and an interface to call data from Sitecore which can be mocked.

Glass allows you to easily create an object model representing your Sitecore templates. If you check out the features page it goes over some of the things we can do with Glass.

Below is a model I've whipped up for the application we have been working with so far. These are not auto-generated, I did these by hand just as an example. In our model we have the following Interfaces: IItem, the base representation of a Sitecore item; IDocument, the core of all browseable pages; IMetaData, used on all browseable pages; IBasePage, which is where we tie in all the inherited Interfaces; IHomePage, a specific version of IBasePage (right now there is nothing specific but there will be!); and HomePage, a concrete Class based on IHomePage.

All this is awesome on its own but there is a lot more you can do with it. Mike has created a great tool for us in Glass Mapper. I recommend hitting up the tutorials over at or joining the Google Group. You can follow Glass on Twitter but it's mostly project updates.