If you're creating content which has the same document type then you might have to search by name.
If you get the root node you can search its descendants and detect if there's any which match the name. You should specify the document type in DescendantOrSelf() to narrow the results down (just in case you have nodes with the same name).
E.g.
var nodeExists = new UmbracoHelper(UmbracoContext.Current).TypedContentAtRoot().DescendantsOrSelf("documentType").Any(n => n.Name == nameVariable);
Check if content page already exists
I am creating content pages programmacatically. I would like to check if the page was created before creating again.
How do I retrieve a content page by alias to see if it exists already?
If you're creating content which has the same document type then you might have to search by name.
If you get the root node you can search its descendants and detect if there's any which match the name. You should specify the document type in DescendantOrSelf() to narrow the results down (just in case you have nodes with the same name).
E.g.
Hi thanks for your reply... Im having issues with the word Any...
My bad... had missed the
using System.Linq;
Thanks for help ;)
Thank you, this helps. What are the parameters that it will compare to check the same?
is working on a reply...