4
I have a generic repository and I realized that it is taking too long to return a query with the selection of some columns of my database, the Query() method is as follows:
public IList<T> Query(System.Linq.Expressions.Expression<Func<T, bool>> Where)
{
return Entity.AsExpandable().Where(Where).AsQueryable<T>().AsNoTracking<T>().ToList();
}
If you observe at the end I still use Take(10), but analyzing the code, there is a field called 'source' that shows 17822 records, so regardless of selecting 10 or 1000, it seems to me that it is always bringing all the records, follows image:
My question is whether I’m with some Entity configuration to always have this behavior or my query call is wrong?
Thank you
Leo
where are you using the
Skip
andTake
, before or after theToList
?– Ricardo Pontual
I’m using take after Tolist
– user2929918
When you use the
ToList
it brings the result, then filtering withTake
, so it’s bringing "everything". You can leave theToList
to the end to settle this– Ricardo Pontual