???????????????????????????????????ORM?????????LINQ????????Skip??Take?????????????????????????????洢????????????SQLServer?????洢???????????????к??????????????????????????????????θ?Ч???????????????????????????????????????????????????????????????
????? ????
??????????SQLServer??????????NorthWind??????????????Product????????????????????????UnitPrice???????У????????????10???????????????????????????????????
?????? ???
????Top???
????????????????????????????Top?????? ?????????????????C#???????????????????? ???????????????????? * ????????????????滻???????????????????????ɡ?
SELECT TOP (@pageSize)
*
FROM    ( SELECT TOP ( @pageSize * @pageIndex )
*
FROM      [Northwind].[dbo].[Products]
ORDER BY  UnitPrice DESC
) AS product
ORDER BY product.UnitPrice
????????????????????????????????λ????????С?????????????????С????????????????????????????????????????磬????????????Products???? 77 ???????????10?????????8????÷???7?????????9???÷????????????????????????ζ?????10???????
??????????????·????????????????2???????Select????????????м?????????????????????Top PageSize??????NOT IN ??????????е?????????????????NOT IN?????????????????е?bug
SELECT  *
FROM    dbo.Products
WHERE   ProductID IN (
SELECT TOP ( @pageSize )
ProductID
FROM    dbo.Products
WHERE   ProductID NOT IN ( SELECT TOP ( @pageSize * (@pageIndex-1) )
ProductID
FROM     dbo.Products
ORDER BY UnitPrice DESC )
ORDER BY dbo.Products.UnitPrice DESC )
ORDER BY dbo.Products.UnitPrice ASC
???????ROW_NUMBER ???????
????????????????????·???????????????????????д???????????????????а???????????У????????У?????????????????????????????????????У??????????????????к????????????????SQLServer 2000?У?????????????????????????????????????????????????????Ч?????????????????
??????SQLServer2005????????ROW_NUMBER() ?????????????????????????????????????ι???????????????????÷????
????SELECT  ROW_NUMBER() OVER ( ORDER BY dbo.Products.ProductID DESC ) AS rownum ??
????*
????FROM    dbo.Products