Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • nickornotto 403 posts 907 karma points
    Nov 12, 2015 @ 18:55
    nickornotto
    0

    GroupBy not working for descendants

    I'm trying to group descendants of home node.

    I tried

    var pages = home.Descendants("TextPage").Where("!Disabled").GroupBy("type")
    

    and this returns type Umbraco.Web.Dynamics.DynamicGrouping

    and if I try to loop trough nodes

    @foreach (var page in pages)
    {
        @(attraction.GetValue("type"))<br />
    }
    

    I'm getting error saying

    'object' does not contain a definition for 'GetValue'

    GetPropertyValue does not work either

    This does not work either:

    var pages = home.Descendants("TextPage").Items.Where(x => x.GetPropertyValue<string>("type") == "something");
    

    and throws:

    Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type

    var pages = home.Descendants("TextPage").Items.Count();
    

    returns

    'Umbraco.Web.Models.DynamicPublishedContentList.Items' is inaccessible due to its protection level

    I've no idea what else to try and why it doesn't work as I saw many examples of groupby and made my stuff same way.

    I tried frst in Macro partial then in template directly, both don't work :(

Please Sign in or register to post replies

Write your reply to:

Draft