【问题标题】:Write SQL query to Entity Framework将 SQL 查询写入实体框架
【发布时间】:2017-09-08 07:26:45
【问题描述】:
select * 
from [InterViewerComment]   
where commentID in (select max(commentID) as commentID 
                    from [InterViewerComment] 
                    where jobID = 45 
                    group by qenID) 

这个查询在 SQL 中是正确的,但我想在实体框架中重写它。 基本上,我想要基于作业 ID 的每个 qenID 的最新评论。

【问题讨论】:

  • 到目前为止你做了什么?林克?
  • 不知道如何在实体框架中进行嵌套级别查询,最后我使用了其他方式

标签: entity-framework-6


【解决方案1】:

同样的方法

var query = " select qendidateList.qenName,InterViewerComment.*, Candidate_status.status, 0 作为 ExamMarks, 0 作为 [InterViewerComment] 的技能 " + " 在 InterViewerComment.qenID = qendidateList.qenID 上左外连接 qendidateList " + " 在 InterViewerComment.candidate_status = Candidate_status.Candidate_status 上的左外连接候选状态" + " where commentID in( select max(commentID) as commentID from[InterViewerComment] where jobID = 45 group by qenID)";

        var CandidateComm_ = db.Database.SqlQuery<interViewerComment>(query).ToList();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多