Skip to content

Known issues

Andrew Gubskiy edited this page May 8, 2021 · 2 revisions

You have to order your IQueryable

Source: https://github.com/dncuug/X.PagedList/issues/185

If you pass an IQueryable from a database without any keyselector, then the results aren't guaranteed.

The generated SQL (For sql server) is as follows

SELECT [a].[WtgId], [a].[TimeOnUtc], [a].[Code], [a].[AlarmType], [a].[Controller], [a].[Guid], [a].[SourceId], [a].[StationId], [a].[Text], [a].[TimeOffLocal], [a].[TimeOffUtc], [a].[TimeOnLocal], [a].[Vendor], [a].[VendorData], [a].[Version], [a].[WindFarmId]
FROM [alarms] AS [a]
ORDER BY (SELECT 1)
OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY 
where ORDER BY (SELECT 1) doesn't actually enforce any ordering.

This means that if you use the same queryable multiple times, the results are non-deterministic. As the paginated list just seems to use skip & take, this means that the paginated list will be out of order, and you can get duplicated values while paginating through.

Clone this wiki locally