Retrive children of current item using GlassMapper

119 Views Asked by At

if we already have current item in a serivce/repository then how we can get children of that item using glass ? I don't see mvcContext or SitecoreService has GetChildren related method

1

There are 1 best solutions below

1
Marek Musielak On

Glass Mapper has IItemFactory which you can inject to your code with dependency injection.

And then you can use

_itemFactory.SelectChildren<ChildType>(parentObject)
_itemFactory.SelectChildren<ChildType>(parentItem.ID.ToGuid())

You should be able to get children also using

parentObject.Children<ChildType>()