如何通过LINQ生成此特殊查询?

时间:2012-09-25 14:42:57

标签: mysql linq join

  

可能重复:
  Need a linq to generate itself 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)

好的,我试过......

var res =
    from item in 
        (from newsItem in news
        where newsItem.cat_id = x
        select newsItem.id).Skip(m).Take(n)

    join other in news
    on other.id equals item.id

    select item