//辅助方法 static void Test(MbsEmployesCategoryView pN, Listls) { foreach (MbsEmployesCategoryModel item in ls) { if (pN.ID == item.ParentID) { var cN = new MbsEmployesCategoryView { ID = item.ID, EmployeCategoryCode = item.EmployeCategoryCode, EmployeCategoryName = item.EmployeCategoryName, EmployeCategoryDescribe = item.EmployeCategoryDescribe,ParentID=item.ParentID }; var jsonData = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cN); pN.Childs.Add(cN); Test(cN, ls); } } }