We are facing issue in Glass mapper 4.0 where it does not load item children.
Here is our controller class , It is inheriting from GlassController:
public class CarouselController : GlassController
{
public ActionResult GetCarousel()
{
Model = this.GetDataSourceItem<CarouselViewModel>();
return View(Model);
}
}
And here is our View Model:
public class CarouselViewModel:Carousel_Folder
{
[SitecoreChildren]
public virtual IEnumerable<Carousel> Carousels { get; set; }
}
we get only the parent node information not the childeren (carousels) in the result
Here is the result we get:
[Result Image][1]
Also, following classes were generated with TDS:
[SitecoreType(TemplateId = ICarousel_FolderConstants.TemplateIdString )] //, Cachable = true
public partial interface ICarousel_Folder : IGlassBase
{}
Carousel template is inheriting from two templates content base and image base.
I had this issue before, for me i added [SitecoreChildren(IsLazy = false)]
to my model and it works fine, in your case it should be like this :
public class CarouselViewModel:Carousel_Folder
{
[SitecoreChildren(IsLazy = false)]
public virtual IEnumerable<Carousel> Carousels { get; set; }
}