sitecore

Glass Mapper

Introduction#

Glass.Mapper is the awesome Open Source mapping framework that allows you to focus on solving your business problems. It does the hard work of converting data from your CMS to something your code can work with.

Using Glass.Mapper and your favourite CMS you can map data to strongly typed models in your C# code. Your models do not require any special mark-up to work with Glass.Mapper and almost no configuration to get started.

Remarks#

Visit this url for tutorials https://glass.lu/Mapper/Sc/Tutorials

The easiest way to map Sitecore data to code.

Glass.Mapper.Sc allows you to move your data from Sitecore and into your code seamlessly using strongly typed objects.

The framework allows you to map data on to c# classes and interfaces without any additional mark-up. As the data is mapped to your target objects it is converted to the target type. Take a look at this simple example:

public class Demo
    {
        public virtual Guid Id { get; set; }

        public virtual string Title { get; set; }

        public virtual DateTime Date { get; set; }

        public virtual string Url { get; set; }
    }


    public void DoWork(
            ISitecoreContext sitecoreContext)
    {
        var model = 
            sitecoreContext.GetCurrentItem<Demo>();

        var url = model.Url;
    }

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow