0

我将不胜感激将以下 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.

提前致谢。

4

1 回答 1

0

我认为 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);
于 2012-05-18T00:45:19.047 回答