Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

linq query to fetch parent child data from same table in c#

var v = from p in db.tableName
        select new
        {
          ParentID = p.SerialNo,
          child = from c in db.tableName
                  where c.Parent == p.SerialNo select
                  new
                  {
                    ChildID = c.SerialNo,
                    ParentID = c.Parent
                  }
        };
 
PREVIOUS NEXT
Tagged: #linq #query #fetch #parent #child #data #table
ADD COMMENT
Topic
Name
5+2 =