Linq to Entities嵌套子查询

时间:2013-04-10 22:10:24

标签: entity-framework linq-to-entities

我对linq很新,并且在将以下sql转换为linq时遇到问题:

select 
    c3.COURSE, c3.DESCR
from 
    (select c.courseprefix, MAX(c.coursesuffix) [coursesuffix]
    from 
        (select distinct SUBSTRING(course,1,3)[courseprefix], RIGHT(course, LEN(course) - 3) [coursesuffix]
        from PsCourses where LEN(course) >= 3 ) c
    group by c.courseprefix 
    ) c2 inner join PsCourses c3 on (c2.courseprefix + c2.coursesuffix) = c3.COURSE
where
    c3.COURSE_STATUS = 'A'
order by
    c3.course

1 个答案:

答案 0 :(得分:2)

好吧,你可以使用http://www.sqltolinq.com/downloads 或者你可以创建一个IQueryable,但在我的个人标准中,我更喜欢用本机sql写的复杂查询