It depends on the type of context .
If it is an Entity Framework or Linq to SQL query, and context is IQueryable<T> , then the query turns into an SQL query on the server, which returns only a number as a single whole.
If it is a collection in memory (i.e. IEnumerable<T> ), each element is repeated in sequence (Linq to Objects) and counted.
I suspect the first is true, since you mentioned the βtableβ and you are not using LINQ to Dataset extension methods. In this case, you will remain very effective.
source share