6

Is there any direct approach to get descendants(child items and sub child items) of a Sitecore item in Glassmapper model.

I know [SitecoreChildren] can be used in GlassMapper model to get Child items. Is there anything like [SitecoreChildren] we can use to get the descendants

Sitecore - Sitecore 8.1 Update 1 Glass Mapper - 4.1.2.67

Thanks

6

No, there is no option to get all the descendants with a simple Glass Mapper attribute.

You could use SitecoreQuery attribute in theory:

[SitecoreQuery(".//*")]

I'm not saying that getting all descendants is always wrong, but you really need to be careful when you want to use descendants. I guess that's the reason why it's not there as one of the Glass attributes.

The whole list of attributes was posted in another question here:

What are the options for Glass Mapper model attributes?

  • 4
    Just remark that Query.MaxItems setting limits the number of result items in the query. By default it is 260 on Sitecore 8.1. – Tamás Tárnok Feb 19 '18 at 13:19
  • 1
    Get descendants is a weapon, sometime a nuke. – Chris Auer Feb 12 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.