110,534
社区成员
发帖
与我相关
我的任务
分享
public void GetRootNode(int childNodeId)
{
string sql = string.Format("select * from Department where parentId={0}", childNodeId);
////执行查询
int currentId=0;//执行查询找到当前节点
int currentParentId = 0;//执行查询找到当前节点的父节点
if (currentParentId == 0)//如果向上为根,则返回
{
//创建节点并返回
return;
}
else
{
//创建节点,并继续递归
GetRootNode(currentId);
}
}