select *
from [InterViewerComment]
where commentID in (select max(commentID) as commentID
from [InterViewerComment]
where jobID = 45
group by qenID)
此查询在SQL中是正确的,但我想在Entity Framework中重写它。 基本上,我希望根据作业ID为每个qenID提供最新评论。
答案 0 :(得分:0)
其他方式做同样的事情
var query =“选择qendidateList.qenName,InterViewerComment。*,candidate_status.status,0作为ExamMarks,0作为来自[InterViewerComment]的技能”+ “在InterViewerComment.qenID = qendidateList.qenID上留下外连接qendidateList”+ “在InterViewerComment.candidate_status = candidate_status.Candidate_status上留下外连接candidate_status”+ “where commentID in(从[InterViewerComment]中选择max(commentID)作为commentID,其中jobID = 45 by qenID)”;
var CandidateComm_ = db.Database.SqlQuery<interViewerComment>(query).ToList();