Glass Mapper


Glass Mapper is a Sitecore ORM (Object Relation Mapping) created by Sitecore MVP Mike Edwards. An ORM maps data to the objects in your code. Without an ORM you would end up writing a lot more mapping code than you wanted to. Glass Mapper specifically allows you to map data from Sitecore to strongly-typed C# models.




Below is an example of accessing Sitecore items without Glass Mapper. You need to call the Sitecore APIs to: 1) query Sitecore, 2) get back results, 3) create new concrete model classes, and 4) map the results into those model classes.


That is a lot of code. On the contrary, working with Glass looks like this:



There are three related packages:

  • Glass.Mapper.Sc.{Version}
  • Glass.Mapper.Sc.{Version}.Mvc
  • Glass.Mapper.Sc.{Version}.Core

When installing Glass Mapper, two files are generated in the App_Start folder. 1. Never change GlassMapperSc.cs. 2. If you are adding custom configurations to GlassMapperScCustom.cs, be aware it will be overwritten with a NuGet update – hopefully this behavior will change in a future version of Glass.







Comments

Popular posts from this blog

Federated Experience Manager (FXM)

Email Experience Manager (EXM)

Sitecore Products