list获取所有上级

///


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

///
///
///
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)));
}

你可能感兴趣的:(list获取所有上级)