0
所以我試着這樣做:嘗試使用一個變量來自不同的查詢命令查詢
public List<User> GetLeaderBoard()
{
SuperGoalDataClassesDataContext myDB = new SuperGoalDataClassesDataContext();
var userResults = (from u in myDB.Users
orderby (GetUserPoints(u.userID))
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 int? GetUserPoints(int userId)
{
SuperGoalDataClassesDataContext myDB = new SuperGoalDataClassesDataContext();
var codeResults = (from tc in myDB.TriviaCodes
where tc.userID == userId
select tc);
return codeResults.Sum(cd => cd.pointsGained);
}
但我發現了一個錯誤說「法「System.Nullable`1 [System.Int32] GetUserPoints(Int32)'不支持對SQL的轉換。「
任何想法我怎麼能得到這樣的工作?
問候,
Arseney
好吧,我會嘗試... – steryd 2014-10-20 20:41:41
這完美地工作,無須解釋:) 除了事實我需要它OrderByDescending;) 謝謝! – 2014-10-20 21:17:45