4

I am trying to get all items at the current item level. I am using Glass Mapper SitecoreQuery for the same. I am able to get the current item but not able to map all siblings

public class TestModel:BaseModel
{
    [SitecoreQuery("../*")]
    public virtual IEnumerable<Model1> Siblings { get; set; }
}

[SitecoreType(AutoMap = true)]
public class Model1 : BaseModel
{

}

Base Model has all the required fields and correctly mapped. I am actually trying to display all items at the level of current item.

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80
Deb
  • 391
  • 2
  • 20

1 Answers1

0

Add second parameter to SitecoreQuery : IsRelative = true like that:

[SitecoreQuery("../*", IsRelative = true)]
public virtual IEnumerable<Model1> Siblings { get; set; }

It tells Sitecore to start query at your item level instead of starting at the tree root.

You can find more information in the Official Sitecore Glass Mapper Tutorial

Marek Musielak
  • 26,832
  • 8
  • 72
  • 80