Loading

list获取所有上级

/// <summary>
/// 获取所有上级
/// </summary>
/// <param name="list"></param>
/// <param name="ID"></param>
/// <returns></returns>
public static IEnumerable<HelpDocumentType> GetFatherList(IList<HelpDocumentType> list, int ID)
{
var query = list.Where(p => p.ID == ID).ToList();
return query.ToList().Concat(query.ToList().SelectMany(t => GetFatherList(list, t.ParentID)));
}

posted @ 2019-07-02 14:30  WeiYongZhi  阅读(285)  评论(0编辑  收藏  举报