Copied to clipboard

Flag this post as spam?

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


  • Nadine Fisch 159 posts 428 karma points
    Sep 14, 2017 @ 08:08
    Nadine Fisch
    0

    select dynamicObjects

    Hi,

    I'm really, really new to Umbraco and razor, but I have to implement new features in Umbraco project.

    So I need some advices, because I'm not fully familiar with the syntax and the possibilites. And I do not exactly know how to use the dynamicObjects-Syntax, and I don't even know the correct term for this :)

    I want to select all children from all nodes from a certain hierarchy level.

    I think about a structure like this:

    var list = new List<dynamic>( node1.children.And.node2.children.where());
    

    Does anyone understand my problem and know how I can achieve this? Or do you have some enlightening tutorials about using dynamicObjects

    Thank you

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Sep 14, 2017 @ 10:22
    Alex Skrypnyk
    0

    Hi Nadine

    Welcome to our forum!!!

    First of all, do not use dynamics with Umbraco, use strongly typed objects if it's possible :)

    Read this "Common Pitfalls Tutorial" - https://our.umbraco.org/documentation/reference/Common-Pitfalls/

    Thanks,

    Alex

  • Nadine Fisch 159 posts 428 karma points
    Sep 14, 2017 @ 10:40
    Nadine Fisch
    0

    Thank you :-)

    yeah the current project here is full of dynamics. So, I tried to do this in the same way, but thank you for your link and your feedback.

    Can you say what happens in Umbraco 8, if IPublishedContent will be removed? I saw this hint in your document. Will I have to rewrite all the code with the current "dynamicObject" - solution ?

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Sep 14, 2017 @ 11:16
    Dan Diplo
    101

    I believe Umbraco 8 will remove all dynamic, so it may well require rewriting all these (or, at very least, suffering warnings they are deprecated).

    You can find more general docs on strongly-typed querying here: https://our.umbraco.org/documentation/Reference/Querying/IPublishedContent/

    I may be misunderstanding, but if you want to select all nodes from a common ancestor then you can use the Descendants. So you could do:

    var list = ancestor.Descendants();
    

    You can just get descendants of a particular document type alias by adding the alias as a parameter:

    var list = ancestor.Descendants("newsItem");
    
  • Nadine Fisch 159 posts 428 karma points
    Sep 14, 2017 @ 12:08
    Nadine Fisch
    0

    Thank you this solution works for me :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies