linQ 我要查询A表 第5条到第10条记录怎么写?
linQ我要查询A表第5条到第10条记录怎么写?SQL的我知道selecttop10*fromawhereidnotin(selecttop5idfroma)...
linQ 我要查询A表 第5条到第10条记录怎么写? SQL的我知道 select top 10 * from a where id not in (select top 5 id from a)
展开
1个回答
展开全部
使用的是SKIP从第几条记录索取,是从0开始计算的哦!,Take 取5条。
linq sample:
(from n in Products select n.Auto_ID).Skip(4).Take (5)
转化的SQL 是:
-- Region Parameters
DECLARE @p0 Int SET @p0 = 4
DECLARE @p1 Int SET @p1 = 5
-- EndRegion
SELECT [t1].[Auto_ID]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Auto_ID]) AS [ROW_NUMBER], [t0].[Auto_ID]
FROM [Product] AS [t0]
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY [t1].[ROW_NUMBER]
ROW_NUMBER() OVER 的方式,走排序。
linq sample:
(from n in Products select n.Auto_ID).Skip(4).Take (5)
转化的SQL 是:
-- Region Parameters
DECLARE @p0 Int SET @p0 = 4
DECLARE @p1 Int SET @p1 = 5
-- EndRegion
SELECT [t1].[Auto_ID]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Auto_ID]) AS [ROW_NUMBER], [t0].[Auto_ID]
FROM [Product] AS [t0]
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY [t1].[ROW_NUMBER]
ROW_NUMBER() OVER 的方式,走排序。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询