Glass.Mapper.Sc in the next release 3.1.5 you will be able to get items through the SitecoreService and SitecoreContext. Lets see how we can use this.

Get an Item using a Glass Service

First off we can directly get a Sitecore item from the SitecoreService or SitecoreContext just by specifying it as the requested type:

    var context = new SitecoreContext();
    var item  = context.GetItem<Sitecore.Data.Items.Item>("/sitecore/content/home");

Using Items on Models

You can also specify Items to be returned on your models as well, look at the example of getting the parent and children as Items on this model:

    public class MyModel{
        public virtual Item Parent{ get; set; }
        public virtual IEnumerable<Item> Children{ get; set; }

Hopefully this will allow better integration with underlying Sitecore API and a more fluid transfer from one environment to another.

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