0
我寫了一個查詢從tbl中選擇最高記錄。我要檢查,如果沒有記錄在TBL我的查詢返回像(StudentId = 1,高分= 0)假數據
IF NOT EXIST Recored選擇一些數據
var queryWin = (from T in ((from tbl_ActPoints in dc.tbl_ActPoints
select new
{
tbl_ActPoints.StudentId,
tbl_ActPoints.Score
}))
group T by new
{
T.StudentId
} into g
orderby
((System.Int32?)g.Sum(p => p.Score) ?? (System.Int32?)0) descending
select new
{
g.Key.StudentId,
HighScore = ((System.Int32?)g.Sum(p => p.Score) ?? (System.Int32?)0)
}).Take(1);
它不工作,我必須在哪裏使用此代碼? –
編輯了答案 – coolswastik