mrahhal/MR.EntityFrameworkCore.KeysetPagination

Unable to get the Last page working

Closed this issue · 5 comments

Hi,

I'm trying to get the "Last page" logic working. But it keeps returning the same first page rows. I following of logic mentioned in the documentation to use "backward"

searchResultsQuery.KeysetPaginate(_keysetBuilderAction, KeysetPaginationDirection.Backward);

but it keeps returning the same first page results. My query uses multiple joins across multiple tables using EF Core lambda. As EF Core doesnt support DistinctBy so I'm using .GroupBy(z=>z.Id).Select(g=>g.First()) for getting the Distinct rows in my query, is this causing an issue finding the last page ?

Hi. A minimal repro would really help, as I won't be able to tell just from what you explained. Not sure how .GroupBy(z=>z.Id).Select(g=>g.First()) factors into this, would need to see the full code in a repro.

Would also help if you try to run the sample in this repo and double check there. If the sample works that means something's wrong with either how you're building this query or maybe there's an edge case in what you're using.

I'm closing this, please reopen if you still have issues.

Facing the same issue, GroupBy does not preserve order of records, so it would be problematic to have it before Take(), @mrahhal is this a known issue?

No there's no known issue right now. If you could give me a minimal repro as I mentioned above I'd be able to look at and investigate, otherwise not much I can do since I can't reproduce it. Alternatively, you could try to open a PR with a test that fails and shows what you're trying to do.

But I don't think there are tests using a GroupBy right now, so maybe it's a case I haven't come across. It's probably just EF doing what it usually does, so maybe this is just doesn't play nice with keyset. A test showing exactly the query you're trying to do would still be helpful.