Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Find Full path all the Child node

Find Full path all the Child node

Scheduled Pinned Locked Moved ASP.NET
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rohit2013
    wrote on last edited by
    #1

    I am having table in Parent Child relation as following:

    ID Node Name ParentID
    1 Node 1 0
    2 Node 2 0
    3 Node 21 2
    4 Node 22 2
    5 Node 21 1 3
    6 Node 3 0
    7 Node 4 0
    8 Node 41 7

    I want the to write the all the child node as following output using the Entity Framework (not code Firt) or using simple dataTable. Expected Output:

    Node 1
    Node 2 > Node 21 > Node 21 1
    Node 2 > Node 22
    Node 3
    Node 4 > Node 41

    Thanks, Rohit

    P 1 Reply Last reply
    0
    • R Rohit2013

      I am having table in Parent Child relation as following:

      ID Node Name ParentID
      1 Node 1 0
      2 Node 2 0
      3 Node 21 2
      4 Node 22 2
      5 Node 21 1 3
      6 Node 3 0
      7 Node 4 0
      8 Node 41 7

      I want the to write the all the child node as following output using the Entity Framework (not code Firt) or using simple dataTable. Expected Output:

      Node 1
      Node 2 > Node 21 > Node 21 1
      Node 2 > Node 22
      Node 3
      Node 4 > Node 41

      Thanks, Rohit

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      I think you can achieve through the self join, please follow below query:

      var query =
      from e1 in Employee
      join e2 in Employee on e1.ManagerID equals e2.ID
      select new
      {
      Employee = e1.FirstName + " " + e1.LastName,
      Manager = e2.FirstName + " " +e2.LastName
      };

      Parwej Ahamad

      R 1 Reply Last reply
      0
      • P Parwej Ahamad

        I think you can achieve through the self join, please follow below query:

        var query =
        from e1 in Employee
        join e2 in Employee on e1.ManagerID equals e2.ID
        select new
        {
        Employee = e1.FirstName + " " + e1.LastName,
        Manager = e2.FirstName + " " +e2.LastName
        };

        Parwej Ahamad

        R Offline
        R Offline
        Rohit2013
        wrote on last edited by
        #3

        no, I am not looking for only 2 level as Employee and his Manager. I need the display the full path of each child and if there is any child of any parent in that case need not to display the parent just display child full hierarchy.

        Thanks, Rohit

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups