Problem retrieving paged data

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
mnewman
Posts: 1
Joined: Mon 24 Jun 2013 16:28

Problem retrieving paged data

Post by mnewman » Mon 24 Jun 2013 16:56

I'm having a problem where I'm trying to retrieve data from a table in paged chunks using the Linq IQueryable helpers Skip and Take so something like

Code: Select all

context.Table.Skip(x).Take(y)
LinqConnect generates this SQL:

Code: Select all

SELECT [t1].Column1, ...
FROM (
	SELECT [t2].Column1, ...,
	ROW_NUMBER() OVER (ORDER BY [t2].Column1, ...]) AS [rnum]
    FROM (
		SELECT [t3].Column1, ...
		FROM Table [t3]
		) [t2]
    ) [t1]
WHERE ([t1].[rnum] > @p0) AND ([t1].[rnum] <= @p1)
ORDER BY [t1].[rnum]
	-- @p0: Input Int (Size = 0; DbType = Int32) [x]
	-- @p1: Input Int (Size = 0; DbType = Int32) [y]"
However the value passed to Take is not the upper index it's the number of items past x to take. If we use real numbers lets say we want page two with a page size of 10 (skip 10, take 10) we end up with an expression that can't true

Code: Select all

([t1].[rnum] > 10) AND ([t1].[rnum] <= 10)
so really it should be more like this:

Code: Select all

..snip...
WHERE ([t1].[rnum] > @p0) AND ([t1].[rnum] <= (@p0 + @p1))
..snip...
using the previous example would be:

Code: Select all

..snip...
WHERE ([t1].[rnum] > 10) AND ([t1].[rnum] <= 20)
..snip...
I'm currently on 4.2.229.0, has this been already fixed and we just need to upgrade or is this a new bug?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Problem retrieving paged data

Post by MariiaI » Tue 25 Jun 2013 09:05

We couldn't reproduce this issue with the latest build of LinqConnect 4.2.272. Please try updating LinqConnect to the latest one and notify us about the results.
If the issue still persists with the latest one, please send us a simple test project with which this issue could be reproduced.

Post Reply