Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert Ghafoor 33 posts 95 karma points
    Feb 28, 2020 @ 00:18
    Robert Ghafoor
    0

    Working with EntityContainers in V8

    In version 7 we could check if there were any children of a EntityContainer by using HasChildren property this is removed in 8 how can we tell if a entity container has any children? HasPendingChanges is also gone how do we check that in 8 ?

    Not important but still curious how can we get childrens of a specific EntityContainer? i noticed the ParentId will we have to get entity containers using the DataTypeService and add logic to determind if someting is a child of someting ?

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Feb 28, 2020 @ 14:28
    Kevin Jump
    100

    Hi,

    In v8 you can use the EntityService to get an IEntitySlim for the container and then check HasChildren to see if it has any.

    e.g

    var container = entityService.Get(containerId, UmbracoObjectTypes.DataTypeContainer);
    if (container.HasChildren)
    {
    
        // actually get the children
        var children = entityService.GetChildren(containerId, UmbracoObjectTypes.DataTypeContainer);
        if (children.Any())
        {
            // do stuff
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft