linq递归组织结构

///


/// 获取所有上级
///

///
///
///
public static IEnumerable GetFatherList(IList list, int ID)
{
var query = list.Where(p => p.ID == ID).ToList();
return query.ToList().Concat(query.ToList().SelectMany(t => GetFatherList(list, t.ParentID)));
}

你可能感兴趣的:(c#开发经典,c#)