So what are you actually trying to do? Looks like you want to look at the parent for some value and then want to search the whole site for that property value?
Just as an example, if you want to get to the parent you can just use Model.Up() and get the property value from that first, then search the whole site.
I have a bunch of 'specials' that each have a parent venue. What I'm trying to do is find the specials where the parent venue is in a specific city. Make sense?
Not sure if you could do this in a single-line statement. How about you go find all of the "specials" and iterate through them to filter the ones you need (untested):
@{ var specials = Model.AncestorOrSelf().DescendantsOrSelf("special"); var specialsForCity = new List<DynamicNode>(); foreach (var node in specials) { if (special.Up().CityName == "MyCity") { specialsForCity.Add(node); } } }
This could be a more consise LINQ statement, but let's just see if this works, compacting it down will hinder debugging at first (IMHO).
You could also take it the other way around by the way, finding all nodes with your city and then iterating to their children of type "special" might be faster.
Search by parent property
Is it possible to do something like:
var results = Model.AncestorOrSelf().DescendantsOrSelf("SomeNodeTypeAlias").Where("Parent.SomeProperty = \"Some Value\"");
??? I'm just doing it wrong?
So what are you actually trying to do? Looks like you want to look at the parent for some value and then want to search the whole site for that property value?
Just as an example, if you want to get to the parent you can just use Model.Up() and get the property value from that first, then search the whole site.
I have a bunch of 'specials' that each have a parent venue. What I'm trying to do is find the specials where the parent venue is in a specific city. Make sense?
Sorry for the delay:
Not sure if you could do this in a single-line statement. How about you go find all of the "specials" and iterate through them to filter the ones you need (untested):
This could be a more consise LINQ statement, but let's just see if this works, compacting it down will hinder debugging at first (IMHO).
You could also take it the other way around by the way, finding all nodes with your city and then iterating to their children of type "special" might be faster.
Will give that a whirl tomorrow morn - think finding the parents first then specials may work...
OK - tried to find all the venues first, then pull out specials (city is parent of venue, venue is parent of special) but something isn't right:
Errors with:
'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Children'
Ideas??
Got it working if I use:
is working on a reply...