Last week I showed you how you could reduce the amount of code you would need to write with Auto-Mapping, however what if you want to write event less configuration? How about not having to write any?

Look at our example HomePage class below, notice that is is a pure C# object with absolutely no configuration!

    public class HomePage
    {
        public virtual string Title { get; set; }
        public virtual string MainBody { get; set; }
        public virtual string Url{ get; set;}
    }

With this class we can now request data from the CMS:

    var homePage = sitecoreContext.GetCurrentItem<HomePage>();

The configuration for the classes is created the first time your request the class, afterwards the configuration is cached to improve performance.

You will need stick to the same rules defined by auto-mapping, and you can't use any static mapping.

Glass needs your support!

Glass.Mappper.Sc is supported by the generous donations of the Glass.Mapper.Sc community! Their donations help fund the time, effort and hosting for the project.

These supporters are AMAZING and a huge thank you to all of you. You can find our list of supporters on the Rockstars page.

If you use Glass.Mapper.Sc and find it useful please consider supporting the project. Not only will you help the project but you could also get a discount on the Glass.Mapper.Sc training and join the Rockstars page.

Become a Rockstar