类型LINQ错误的成员访问不合法



我得到以下错误:

成员访问'System.Nullable 1[System.Int32] pointsGained' of 'SuperGoalSQLDataBase.TriviaCode' not legal on type 'System.Collections.Generic.List 1[SuperGoalSQLDataBase.TriviaCode].

这是我的代码:

 public List<User> GetLeaderBoard()
       {
           SuperGoalDataClassesDataContext myDB = new SuperGoalDataClassesDataContext();
           var userResults = (from u in myDB.Users
                              where u.firstName != null && u.lastName != null
                              orderby (FillUserCodes(u).Sum(co => co.pointsGained ?? 0))
                             select u).Take(100);
           List<User> users = new List<User>();
           foreach (var usr in userResults)
           {
               if(usr.myPoints > 0)
                    users.Add(usr);
           }
           return users;
       }

任何和所有的帮助都将不胜感激

尝试:

public List<User> GetLeaderBoard()
   {
       SuperGoalDataClassesDataContext myDB = new SuperGoalDataClassesDataContext();
       return myDB.Users.Where(u=> u.firstName != null && u.lastName != null).AsEnumerable()
                         .OrderBy(u=> FillUserCodes(u).Sum(co => co.pointsGained ?? 0))
                         .Take(100).Where(u=> u.mypoints > 0).ToList();
   }

最新更新