In this How To we look at how to retrieve an item from the Sitecore database using the path to the item.

Our template has the following two fields:

  • Title - Single Line Text
  • Text - Rich Text

We need to create a model to represent this item:

public class MyModel{
    
    public virtual string Title { get; set; }

    public virtual string Text { get; set; }

}

All properties MUST be marked as virtual.

With this model we can request data from Sitecore.

ISitecoreService service = new SitecoreService();

MyModel model = service.GetItem<MyModel>("/sitecore/content/home");

GetItem can accept either the path to an item or the ID (Guid) of an item.