我有两个表如下:
ScholarSubject
ScholarSubjectID<pk>
ScholarID
SubjectID
Mark
和
AdmissionReq
SubjectID
DegreeCode
MinumumMark
我正在尝试从学位表(带有 PK degreeID)中返回所有内容,其中学者的分数低于录取的最低分数。我的查询如下:
public List<object> getDegreeByAPSandRequirements()
{
using (DataLayer.CareerDatabaseEntities context = new DataLayer.CareerDatabaseEntities())
{
return (from Degrees in context.Degrees
join admissions in context.AdmissionReqs on
Degrees.DegreeCode equals admissions.DegreeCode
join subject in context.Subjects on
admissions.SubjectID equals subject.SubjectID
join scholarsubject in context.ScholarSubjects on
subject.SubjectID equals scholarsubject.SubjectID
join scholar in context.Scholars on
scholarsubject.ScholarID equals scholar.ScholarID
where Degrees.APSScore <= scholar.APSScore && admissions.MinimumMark <= scholarsubject.NSC && scholarsubject.SubjectID.Equals(admissions.SubjectID)
select Degrees).Distinct().ToList<object>();
}
}
一切正常,除非我将其中一个分数(在 ScholarSubject 中)更改为比最低分数(在 AdmissionsReq 中)更小的值,那么它仍然会返回一个学位。如果两个分数都高于最低要求,而不仅仅是一个分数,我想返回学位。
我究竟做错了什么?有人可以帮帮我吗??