Z
Z
z_a_p_a_r_a2019-07-31 00:50:22
ASP.NET
z_a_p_a_r_a, 2019-07-31 00:50:22

What is the best way to get all the data in a linked list?

Model:

public class Department
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int? HeadDepartmentId { get; set; }
        public Department HeadDepartment { get; set; }

        public List<Department> ChildDepartments { get; set; }
    }

The nesting level is not known in advance. how do i get the Department with all the subordinates. as an option is it possible through recursion or can there be some kind of Include that will include all the subordinates and so on until the very bottom?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Malinovsky, 2019-07-31
@z_a_p_a_r_a

You have ChildDepartments, what's wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question