标签:
.net中使用linq递归查询
public IEnumerable<NodeData> GetSonID(string p_id) {
//获取表中所有数据 INodeDataService NodeDataService = new NodeDataService(); var entity = NodeDataService.FindAll();
//查询父节点和给定节点id相同的节点 var query = from c in entity where c.ParentId == p_id select c; var list = query.ToList();
//递归查询节点id和已经查询出来的节点的父节点相同的节点 return query.ToList().Concat(query.ToList().SelectMany(t => GetSonID(t.NodeID))); }
标签:
原文地址:http://www.cnblogs.com/jt789/p/4299152.html