SitecoreQuery attribute that would return the current item

55 views
Skip to first unread message

Dave Brooks

unread,
Sep 25, 2014, 7:49:08 AM9/25/14
to glass...@googlegroups.com

I'm curious if it is possible to construct a Sitecore query attribute (or some other attribute) that would cause Glass to return the same Sitecore item we are currently looking at.

E.g. Something a bit like this:

    public partial class StreamlinedEntity : MinimalSitecoreItem
    {

        public virtual string Title { get; set; }

        public virtual string BodyText { get; set; }

        [SitecoreQuery(".", IsRelative = true)]
        public virtual AdvancedSitecoreItem ExtraInfo { get; set; }
    }

So "ExtraInfo" could be lazy loaded only when more fields are occasionally needed. Would this give a performance gain? If so, is there a way to achieve this? Is this a bad idea? Even if the above Sitecore Query worked (which it doesn't) I realise it would return the context item, not necessarily the item we are expecting so wouldn't be what I am looking for.

Thanks

David

Dave Brooks

unread,
Sep 30, 2014, 7:10:18 AM9/30/14
to glass...@googlegroups.com

I found a solution!

        [SitecoreQuery("fast:{escapedPath}", IsLazy = true)]
        public virtual AdvancedSitecoreItem ExtraInfo { get; set; }


Reply all
Reply to author
Forward
0 new messages