I have the following snippet:
IQueryable<BaseEntity> someQueryble = ApplicationDbContext.BaseEntities;
var randomQueryable = someQueryable.OfType<RandomEntity>()
.Include(prop => prop.SomeRandomNavProp)
.OrderBy(prop => prop.Id);
BaseEntitiesis just DbSetfrom ApplicationDbContextfrom EF 6.
RandomEntityinherits from BaseEntity(table hierarchy for each type)
Then something strange happens:
randomQueryable.Take(10).Count();
10
randomQueryable.Take(10).ToList().Count;
20
When Includeremoved, everything works fine. Why .includedoes it affect ToListand how can I resolve it?
Edit: generated SQL:
http://pastebin.com/SS3WD7P6
Caution is from a production database, so readability can be harmful. The first request is Count, and the second is aboutToList()
source
share