Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 954 karma points
    Nov 21, 2011 @ 13:08
    Tom
    0

    Explanation for DynamicNode behaviour?

    Hey all!

    Just wondering if someone could please explain the following:

     

    I've got the following code:

     @{
          var mediaItems = Library.NodeById(1191).GetChildrenAsList.Items;
          if(mediaItems.Any()) {
             var tvItems = mediaItems.Where(dn => dn.NodeTypeAlias == "Television");
             var radioItems = mediaItems.Where(dn => dn.NodeTypeAlias == "Audio");
             var printItems = mediaItems.Where(dn => dn.NodeTypeAlias == "Radio");
             if(tvItems.Any() || radioItems.Any() || printItems.Any()) {
               <div>moo</div>
             }
          }
        }

    If i do it that way dealing with the variable assignments doesn't work with the lambdas. However if i do it the following using DynamicNode instead of Libray.GetNodeByID, I then get access to the Where clauses.

     @{
          var mediaItems = new DynamicNode(1191).GetChildrenAsList.Items;
          if(mediaItems.Any()) {
             var tvItems = mediaItems.Where(dn => dn.NodeTypeAlias == "Television");
             var radioItems = mediaItems.Where(dn => dn.NodeTypeAlias == "Audio");
             var printItems = mediaItems.Where(dn => dn.NodeTypeAlias == "Radio");
             if(tvItems.Any() || radioItems.Any() || printItems.Any()) {
               <div>moo</div>
             }
          }
        }

    An explanation would be MOST appreciated

Please Sign in or register to post replies

Write your reply to:

Draft