将 SQL 语句转换为 LINQ VS2010

本文关键字:LINQ VS2010 转换 SQL 语句 | 更新日期: 2023-09-27 18:34:37

我将不胜感激将以下sql语句转换为linq的帮助:

select *
from (
    select 
        *,
        rn = row_number() over (partition by ClientId order by VisitId)
    from
        Visit
) activityWithRn
inner join vw_MasterView on  vw_MasterView.VisitId = activityWithRn.VisitId
where activityWithRn.rn =3

当我使用Linqer(一个很棒的程序(时,我收到以下错误:

SQL cannot be converted to LINQ: Field [rn = row_number() over (partition by ClientId order by VisitId)] not found in the current Data Context.

提前谢谢。

将 SQL 语句转换为 LINQ VS2010

我认为 LINQ 中没有任何相应的功能用于row_number() over,除了使用 Skip...Take

var q = (from v in Visit
            join mv in vw_MasterView on v.VisitId equals mv.VisitId 
            orderby v.VisitId
            select v).Skip(2).Take(1);