Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

OU parent children and “deepest” setting #9242


User avatar
0
marble68 created

if using OUs and entities. it's straightforward to get an entity and it's children based on the examples. ( adding keyword for searching Orginazational Units )

How might one leverage this to find the "deepest" value in the tree for a specific child?

For example, if my entities have a nullable property called manager. Lets assume the root entity has a value of Bob.

4 layers deep an entity has the manager property set to a different value, Sharon.

finally, below that, there is an entity for employee, Mike.

How might one find out who Mike's immediate manager is?

if i start with Mike and recusively examine parents upward until i get a value, this can be done.

But if i have 1000s of employees?

is the only solution to do this recursive upward query, or is there a best practice when getting children to get the "deepest" manager to the child?

Can the OU code be leveraged somehow to get the employee element with the manager value of Sharon without recursivly crawling up the OU parents for enery child untill i get a value, each time?

i see this as highly inefficient and would hurt performance.


2 Answer(s)
  • User Avatar
    0
    robert created
    Support Team

    Hello marble68 ,

    Are you trying to get the parent in Angular or from Backend ? If you are using Angular then you can use this TreeDataHelperService in Angular to get the parent or children of any specific node .

    If Backend, then please refer to this documentation link :

    https://aspnetboilerplate.com/Pages/Documents/Zero/Organization-Units. You can use the OU Code to get the desired employee element.. For example :

     var query =
                from product in _productRepository.GetAll()
                join organizationUnit in _organizationUnitRepository.GetAll() on product.OrganizationUnitId equals organizationUnit.Id
                where organizationUnit.Code.StartsWith(code)
                select product;
    
    

    You can find this in the documentation as well.

  • User Avatar
    0
    marble68 created

    I read through that - was just wondering if there's a more efficent way to flatten results.

    This will work