需要一个linq来生成自己的连接

时间:2012-09-25 09:23:19

标签: linq join

根据这篇文章Why does MYSQL higher LIMIT offset slow the query down?和本文http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/我需要一个linq来创建以下查询

SELECT  news.*
FROM    (
        SELECT  id
        FROM    news
        WHERE   cat_id= x
        ORDER BY
                id DESC
        LIMIT m, n
        ) o
JOIN    news
ON      news.id = o.id

1 个答案:

答案 0 :(得分:0)

这应该这样做。 (Skip / Take等于限制)

from u in news
join n in
(
    from x in news
    where x.cat_id = 10
    orderby x.Id descending
    select x
).Skip(10).Take(20) on u.Id equals n.Id
select u