/// <summary> /// DataTable转换到List /// </summary> /// <param name="dt"></param> /// <returns></returns> private void DataTableToList(DataTable dt) { //获取最原始的List var orgList = (from dataTable in dt.AsEnumerable() select new PropertyNodeItem() { ParentName = dataTable["OWNER"].ToString(), ChildrenName = dataTable["TABLE_NAME"].ToString() }).ToList(); OrgList.AddRange(orgList); DataTable newdt = new DataView(dt.Columns["OWNER"].Table).ToTable(true, "OWNER");//去除重复,只留下OWNER //只获得Owner列表 var newList = (from dataTable in newdt.AsEnumerable() select dataTable["OWNER"].ToString()); OwnerList.AddRange(newList); }