我收到以下错误:
会员访问' 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;
}
任何和所有帮助将不胜感激
答案 0 :(得分:1)
尝试:
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();
}