📜  linq 查询以在 c# 代码示例中从同一个表中获取父子数据

📅  最后修改于: 2022-03-11 14:48:43.155000             🧑  作者: Mango

代码示例1
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
                  }
        };