I have navigation elements that are 2 levels down from my root. I have around 650 nodes total. I think this query is looking through all the elements and not just looking through the first few levels.
I'd like to restrict the query to only look for the first <= 3 levels, then apply the where clause. I've tried Decendants(3) but that didn't work.
I get "Expresions cannot contain labmda expressions".
In the mean time I hard coded the nav. Now it takes 5ms :). I might just keep it that way. I would like to know how to do the above query correctly though.
Help me speed up this razor macro
This macro builds my navigation. It takes 2-3 seconds to run. I have it cached, but I'd like it to go faster on first run.
Here's the offending line:
Model.AncestorOrSelf().Descendants().Where("Level <= 3 && " + @Html.Raw(selectionCriteria) + " == true").OrderBy("level, sortOrder"))
I have navigation elements that are 2 levels down from my root. I have around 650 nodes total. I think this query is looking through all the elements and not just looking through the first few levels.
I'd like to restrict the query to only look for the first <= 3 levels, then apply the where clause. I've tried Decendants(3) but that didn't work.
Any ideas how I speed this up?
Hi,
so you like to return _all_ nodes from level 1,2 and 3 which fulfills the condition selectionCriteria?
just an idea, I havent tried it myself but this should limit the loop a bit, especially if the most nodes are on level 4 and below:
.Descendants(3) returns Descendants(n=>n.Level>=3) ref http://umbraco.codeplex.com/SourceControl/changeset/view/20be2d518820#umbraco.MacroEngines.Juno%2fRazorDynamicNode%2fDynamicNode.cs
I get "Expresions cannot contain labmda expressions".
In the mean time I hard coded the nav. Now it takes 5ms :). I might just keep it that way. I would like to know how to do the above query correctly though.
is working on a reply...