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