Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello. I need to know, has a page children or not? I don't need to get any children, I just want to know has it or not.
// BAD WAY page.Children().Count() > 0
There is a EXISTS operator in SQL-syntax, but how to implement it with LINQ fluent syntax?
Or another way to do what I want?
Hi Dmitriy
Any() method is a way how to do it:
if (page.Children().Any()) { }
Thanks,
Alex
Thanks, Alex. But it is not I want.
When page.Children() is done, we have got a full set of children first, I guess it is not good for performance. But may be Umbraco-developers solved that problem somehow. Do you know anything about that?
page.Children()
It's not a performance problem when you are working with IPublishedContent entities, they are not touching database so it's not a problem.
Be aware - do not use IContent entities, they are working with the database.
Read more about common pitfalls: https://our.umbraco.org/documentation/reference/Common-Pitfalls/
Thanks again, Alex, I'll check it.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Optimal way to check page for children
Hello. I need to know, has a page children or not? I don't need to get any children, I just want to know has it or not.
There is a EXISTS operator in SQL-syntax, but how to implement it with LINQ fluent syntax?
Or another way to do what I want?
Hi Dmitriy
Any() method is a way how to do it:
Thanks,
Alex
Thanks, Alex. But it is not I want.
When
page.Children()
is done, we have got a full set of children first, I guess it is not good for performance. But may be Umbraco-developers solved that problem somehow. Do you know anything about that?It's not a performance problem when you are working with IPublishedContent entities, they are not touching database so it's not a problem.
Be aware - do not use IContent entities, they are working with the database.
Read more about common pitfalls: https://our.umbraco.org/documentation/reference/Common-Pitfalls/
Thanks,
Alex
Thanks again, Alex, I'll check it.
is working on a reply...