Home

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 you 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.
With Glass Sitecore Mapper you can spend your time focused on solving the business problem and not writing repetitive boiler plate code to mapping data to and from Sitecore.

To get started download the framework and read the Wiki.

Features overview:

  • Map Sitecore item fields directly to object properties
  • Handle type conversion including IEnumerable<> and IList<>
  • Reading and writing to fields
  • The ability to create properties for children and parents
  • Create, Save and Delete objects directly back to Sitecore
  • Create both classes and interfaces
  • The service that interacts with Sitecore is interfaced to allow unit testing
  • Map item properties directly to object properties e.g. item path, item URL

For more information on these features see the Features page.

The Aim

The aim of the framework is to give the ability to completely model a Sitecore solution and remove the need for complex mapping code, no more of this:

            Database db= global::Sitecore.Configuration.Factory.GetDatabase("web");
            Item homeItem = db.GetItem("/sitecore/content/home");
            HomeClass home = new HomeClass()
            {
                Content = homeItem["Content"],
                Title = homeItem["Title"],
                DateTime = DateUtil.IsoDateToDateTime(homeItem["Date"])
                //keep adding mappings and type conversions
            };

            //do some work

Instead we have something simple like this:

            ISitecoreService service = new SitecoreService("web");
            HomeClass home = service.GetItem<HomeClass>("/sitecore/content/home");
            //no mappings, all handled by the framework

            //do some work

You can see the markup for the HomeClass on the Simplicity page.

Glass integration with Team Development for Sitecore (TDS)

Check out the new tutorial on how you can use Team Development for Sitecore (TDS) to automatically generate classes that can be used by Glass.Sitecore.Mapper. You can access the tutorial here: Tutorial 12 – Team Development for Sitecore (TDS) integration Using this integration you can automatically generate the mappings for majority of you Sitecore solution. …

Read more

Nuget

Introducting Glass.Sitecore.Mapper.Razor

Today I released the beta release of Glass.Sitecore.Mapper.Razor, this offers integration of the Razor view engine with Sitecore and Glass.Sitecore.Mapper. This module will allow you to create Razor views from within the Sitecore Content Editor that seamless work with your strongly typed Glass models as well as taking advantage of the new Dynamic models in …

Read more