public Tuple<List<Site>, int> GetBeLovh() { var sq = @" WITH cte AS ( SELECT * FROM [Site] WHERE BeLock=1 and ParId=0 UNION ALL SELECT p.* FROM [Site] P INNER JOIN cte A ON A.Id = P.ParId ) select * from cte where BeLock=1"; var lst = new List<Site>(); var lstb = base.Entities.Site.SqlQuery(sq).ToList(); DGChild(lstb, 0, ref lst); return new Tuple<List<Site>, int>(lst, 0); } private void DGChild(List<Site> lstb, int parId, ref List<Site> lst) { var lst2 = lstb.Where(y => y.ParId == parId).ToList(); if (lst2.Count() > 0) { foreach (var it in lst2) { if (lst.Where(y => y.Id == it.Id).Count() == 0) { lst.Add(it); } DGChild(lstb, it.Id, ref lst); } } }
如果您也喜欢它,动动您的小指点个赞吧