Debugger will materialize the IQueryable
when you open the results view (as far as I remember it is even mentioned in the debugger, but I maybe confusing IDEs), if you will not try to view the results then it will not query the database and will not return all the items matching the query (in your case the whole Equipment
table, if there are no query filters set).
I thought IQueryable would only run the query on operations like ToList()
Yes, exactly, IQueryable
(as IEnumerable
, but there is a caveat when casting the former to latter, then EF will need to materialize the data - see Client vs. Server Evaluation) is lazy and the actual operation will be performed only when materialization operation will happen (ToList
, Any
, Count
etc.)
Does that mean that q.Any() also performs a database call (select *)
You are using EF Core, so no, it does not. It will perform select exists (...)
or something similar. You can enable actual query logging - for example using simple logging to console.
Read more: