开发者

Help with this Linq query

I'd like to get a collection of Students whose average grade (by adding each individual subject score and dividing by the amount of subjects) is above 55.

Since this year is 2011, I also need to calculate this field only for the 2011 records.

Help with this Linq query

private void cmbGr开发者_如何学编程adeParalelo_SelectedIndexChanged(object sender, EventArgs e)
{
    StudentRepository studentRepo = new StudentRepository():
    dataGridView1.DataSource = studentRepo.FindAllStudents()
                                          .Where(s=>s.ScoreRecords.)
}

Any suggestions?


Assuming every student may have multiple ScoreRecords, maybe try

dataGridView1.DataSource = studentRepo.FindAllStudents
                                      .Where(s=> s.ScoreRecords
                                                  .Where(r => r.Year == 2011)
                                                  .Average(r => r.FinalGrade) > 55) 


.Where(s=>s.ScoreRecords.Year == 2011).Average(f => f.FinalGrade) > 55));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜