var x = CurrentPage.AncestorOrSelf(1).Descendants(docType).Where(x => x.GetPropertyValue
On a sidenode... you may run into a serious performance issue if you're using Descendants() on a top level node, as it will iterate every single node in your node structure... Image if you'd have 10000 nodes
Don't know the context, so can't suggest alternatives atm.
In terms of performance, here are some alternatives... YMMV
XPath, baby!
var xpath = string.Format("//{0}[@isDoc and {1} = '{2}']", "DocTypeAlias", "propertyAlias", "matchingtext");
var items = Umbraco.TypedContentAtXPath(xpath);
XPath is super fast, but gets a bad rap because no one really likes XSLT anymore... and no one knows what the performance will be like once NuCache is the default cache in Umbraco v8. But while we've still got an XML cache, XPath is best IMHO.
Examine, baby!
var query = ExamineManager.Instance.CreateSearchCriteria()
.NodeTypeAlias("DocTypeAlias")
.And()
.Field("propertyAlias", "matchingtext")
.Compile();
var results = Umbraco.TypedSearch(query);
Also super fast, but there's a lot more configs/switches to play around with. This may or may not be a good thing for you.
If you want to know more about Examine, here are a couple of great posts:
Just to note, there's nothing wrong with using Linq queries - I use them all the time - it's a case of knowing when to use them and if there are better tools for the job. As Dirk says, using Descendants() from the root node will become a performance nightmare.
Where condition in desendents
Hi
I just wanted to put a where clause after Descendants
How can i achieve this
Manish
var x = CurrentPage.AncestorOrSelf(1).Descendants(docType).Where(x => x.GetPropertyValue
On a sidenode... you may run into a serious performance issue if you're using Descendants() on a top level node, as it will iterate every single node in your node structure... Image if you'd have 10000 nodes
Don't know the context, so can't suggest alternatives atm.
-Dirk
In terms of performance, here are some alternatives... YMMV
XPath, baby!
Examine, baby!
Also super fast, but there's a lot more configs/switches to play around with. This may or may not be a good thing for you.
If you want to know more about Examine, here are a couple of great posts:
Just to note, there's nothing wrong with using Linq queries - I use them all the time - it's a case of knowing when to use them and if there are better tools for the job. As Dirk says, using
Descendants()
from the root node will become a performance nightmare.Cheers,
- Lee
Thanks Lee Kelleher
is working on a reply...
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.