Skip and take ignored when query has join
Posted: Sat 18 Jan 2020 08:56
I have 2 tables with a one to many relation.
When I run this query, I get all of the cars, and the skip and take is ignored.
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?
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>();
}
Code: Select all
List<Car> cars = await DbContext.Cars.Include(c => c.Person).Skip(1).Take(1).ToListAsync();
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?