Skip and take ignored when query has join

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
richardgergely
Posts: 2
Joined: Sat 18 Jan 2020 08:43

Skip and take ignored when query has join

Post by richardgergely » Sat 18 Jan 2020 08:56

I have 2 tables with a one to many relation.

Code: Select all

public class Car
{
    public int Id { get; set; }
    public string LicencePlateNumber { get; set; }

    public int PersonId { get; set; }
    public Person Person { get; set; }
}

public class Person
{
    public Id { get; set; }
    public string Name{ get; set; }

    public ICollection<Car> Cars { get; set; } = new HashSet<Car>();
}
When I run this query, I get all of the cars, and the skip and take is ignored.

Code: Select all

List<Car> cars = await DbContext.Cars.Include(c => c.Person).Skip(1).Take(1).ToListAsync();
When I remove the include, so there is no join in the query, it returns only the expected one car.

I've tried EF Core 3 and 3.1, both produces the same result, but on EF Core 2.2 it works correctly.

Can you please check it?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Skip and take ignored when query has join

Post by Shalex » Mon 20 Jan 2020 20:36

When I run this query, I get all of the cars, and the skip and take is ignored.

Code: Select all

List<Car> cars = await DbContext.Cars.Include(c => c.Person).Skip(1).Take(1).ToListAsync();
1. Please enable the dbMonitor tool and specify the generated SQL statement.
2. You are working with v9.10.909, aren't you?
3. Tell us the version (xx.x.x.x) of your Oracle Server.

richardgergely
Posts: 2
Joined: Sat 18 Jan 2020 08:43

Re: Skip and take ignored when query has join

Post by richardgergely » Tue 21 Jan 2020 07:01

1.
This was the SQL without include:

Code: Select all

SELECT "t".ID, "t".LICENCEPLATENUMBER, "c".PERSONID
FROM (
    SELECT "c".ID, "c".LICENCEPLATENUMBER, "c".PERSONID, ROWNUM "ROWNUM"
    FROM CARS "c"
) "t"
WHERE ("t"."ROWNUM" > :p__p_0) AND ("t"."ROWNUM" <= (:p__p_0 + :p__p_0))

p__p_0 = 1
And this is what I get with include:

Code: Select all

SELECT "t".ID, "t".LICENCEPLATENUMBER, "t".PERSONID, "p".ID, "p".NAME
FROM (
    SELECT "c".ID, "c".LICENCEPLATENUMBER, "c".PERSONID
    FROM CARS "c"
) "t"
INNER JOIN PERSON "p" ON "t".PERSONID = "p".ID
2. Yes
3. 11.2.0.4.0

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Skip and take ignored when query has join

Post by Shalex » Tue 21 Jan 2020 09:19

We have reproduced the bug with Oracle 11g and below.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Skip and take ignored when query has join

Post by Shalex » Mon 02 Mar 2020 16:17

The bug with paging in EF Core 3, when using JOINs and subqueries to Oracle 11.2 and below, is fixed in v9.11.951: viewtopic.php?f=1&t=39884.

Post Reply