I was using helper.ContentSingleAtXPath("//pageName") but thats depreched now and will be removed.
Whats the best and most optimal way of getting a (deep) content by its name?
Doing helper.ContentAtRoot().First().Children.Where(x => x.Name == "Foo") seems very unoptimal and SELECT N+1 issue, and it doesn't work if its a deep nested page.
I didn't consider search, probably because I don't exactly know how it works in Umbraco. Search is usually full-text search, and eventually consistent, so doesn't make sense to use full text search to find one item with particular property value, and when you need most recent value. I would expect Umbraco has API for that kind of "exact" querying.
Also, can't cache be stale or empty, even the content is there? I would expect filtering/querying API to use cache behind the scene, and just go to the Db if cache is empty. But as i said, I don't know how Umbraco is designed for these kind of things.
Finding content item by name
I was using
helper.ContentSingleAtXPath("//pageName")
but thats depreched now and will be removed.Whats the best and most optimal way of getting a (deep) content by its name?
Doing
helper.ContentAtRoot().First().Children.Where(x => x.Name == "Foo")
seems very unoptimal and SELECT N+1 issue, and it doesn't work if its a deep nested page.Have you tried to use the examine search? https://docs.umbraco.com/umbraco-cms/reference/searching/examine/quick-start If you need published content, you can find content by node name and then use IUmbracoContextAccessor (_context is IUmbracoContextAccessor)
I didn't consider search, probably because I don't exactly know how it works in Umbraco. Search is usually full-text search, and eventually consistent, so doesn't make sense to use full text search to find one item with particular property value, and when you need most recent value. I would expect Umbraco has API for that kind of "exact" querying.
Also, can't cache be stale or empty, even the content is there? I would expect filtering/querying API to use cache behind the scene, and just go to the Db if cache is empty. But as i said, I don't know how Umbraco is designed for these kind of things.
is working on a reply...