public List <TreeNode> CreateRoleTree(int userID) { List <Role> rolelist = roledal.FindList(u => u.ID, true); var treeList = new List <TreeNode>(); if (rolelist != null && rolelist.Any()) { foreach (var item in rolelist) { var node = new TreeNode(); node.id = item.ID; node.text = item.RoleName; //if (context.UserRole.Any(p => p.UserID == userID && p.RoleID == item.ID)) //{ node.@checked = true;} if (userroledal.FindList(a => a.UserID == userID && a.RoleID == item.ID, a => a.ID, true).Any()) { node.@checked = true; } treeList.Add(node); } } return(treeList); }