-1

我正在尝试编写 linq 查询:

SQL:

select s.s_name, sum(sub.evaluation) as suma from submit_task sub
join student s on s.id=sub.student_id
join study_group g on g.id=s.study_group_id
where g.g_name="abcd"
group by s.s_name
order by suma desc
4

1 回答 1

0
var groupName = "abcd";
var query =
    from submitTask in db.submit_task
    join student in db.student
        on submitTask.student_id equals student.id
    join studyGroup in db.study_group
        on student.study_group_id equals studyGroup.id
    where studyGroup.g_name == groupName
    group submitTask by student.s_name into g
    let suma = g.Sum(st => st.evaluation)
    orderby suma descending
    select new
    {
        s_name = g.Key,
        suma = suma,
    };
于 2013-05-05T23:28:04.103 回答