Copied to clipboard

Flag this post as spam?

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


  • Bilal Haidar 144 posts 410 karma points
    Sep 24, 2018 @ 10:57
    Bilal Haidar
    0

    Best practices querying data inside SurfaceController

    Hello,

    I am reading with Umbraco v8 dynamics will be removed.

    With the latest version of Umbraco v7, even using Node.Children.Where() is obsolete.

    My question is:

    • Inside a SurfaceController, what is the replacement of CurrentPage?
    • How to perform queries inside SurfaceController?

    Thanks Bilal

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Sep 24, 2018 @ 11:24
    Alex Skrypnyk
    1

    Hi Bilal

    The replacement is "Umbraco.AssignedContentItem", try to use it.

    Just use "UmbracoHelper" inside SurfaceController for queries or even better xPath or Examine queries if it's really complex stuff.

    Read more about common pitfalls - https://our.umbraco.com/documentation/reference/Common-Pitfalls/#too-much-linq---xpath-is-still-your-friend

    Thanks,

    Alex

  • Bilal Haidar 144 posts 410 karma points
    Sep 24, 2018 @ 11:41
    Bilal Haidar
    0

    Thanks Alex!

    When you say "UmbracoHelper" this means I can do something like "Umbraco.AssignedContentItem.AncestorOrSelf("home")" inside the SurfaceController and I will be okay without any dynamic stuff?

    As for using xPath or Examine, can you refer me to any tutorial or article on using both for data query? I assume they provide the same functionality as using the Descendants() and other methods?

    Regards Bilal

Please Sign in or register to post replies

Write your reply to:

Draft