需要一个linq来生成自己的连接 [英] Need a linq to generate itself join
本文介绍了需要一个linq来生成自己的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据此帖子为什么MYSQL会提高LIMIT偏移量会减慢查询速度?,本文 http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/我需要使用linq来创建以下查询>
According to this post Why does MYSQL higher LIMIT offset slow the query down? and this article http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/ I need a linq to create below query
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
推荐答案
这应该可以做到. (跳过/获取等于限制)
This should do it. (Skip/Take equals the Limit)
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
这篇关于需要一个linq来生成自己的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文