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.

comments powered by Disqus