Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:52:43+00:00 2026-05-27T05:52:43+00:00

I have a 4 levels deep node structure, where the top most level is

  • 0

I have a 4 levels deep node structure, where the top most level is made of 1 root node.

What I want to do is get all nodes in the 4th level for which a certain property(ies) is true, for example:

get all 4th level nodes where nodePropertyX == true.

Now, I could do this with a for-each loop, and iterate all the items in the levels above, but I have the feeling it would be inefficient.

  1. How can I do it in a better more efficient way ? Is there a way to maybe cache my dataset? (I’m returning results as a datatable) ?

  2. What is the preferrable method: using C# control (.ascx) or razor script (.cshtml)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:52:43+00:00Added an answer on May 27, 2026 at 5:52 am

    Depending on what you want to do with those nodes, you may use razor, macros and the built-in caching abilities for macros to cache the output of the macro:

    Here’s how to get all nodes at the 4th level from the root node having a property nodePropertyX which equals value :

    @foreach (var item in @Model.AncestorOrSelf().Descendants()
        .Where("Visible")
        .Where("level=4")
        .Where("nodePropertyX == \"value\""))
    {
        <a href="@item.Url">@item.Name</a>
    }
    

    Place this code in a Scripting file (Section Developer, node Scripting Files), create a macro using this scripting file, and insert the macro wherever (on any template) you want to display the list of those nodes.

    In order to cache the output of the macro, select the macro and set the appropriate properties (Cache Period, Cache By Page and Cache Personalized).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tree data structure that is L levels deep each node has
I have a tree structure that can be n-levels deep, without restriction. That means
If I have an xml structure like this <root> <sub> <node /> <node />
I have this nested loop that goes 4 levels deep to find all the
I have a directory structure (multiple levels deep) of resources, that I would like
Hey all, I have highly repetitive data with a depth of 5 nodes deep
I have a xml which is max 3 levels deep. Now by using C#
I have a hierarchy of tables 3 levels deep (QualificaionType has many QualificationGroups, which
I have a menu with two levels, the second level shown in the secondary
I have a ASP.Net Menu Control with three levels and flyouts enabled. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.