Linq To Sql: Compiled Queries and Extension Methods
I am wondering how Linq2Sql handles a compiled query that returns an IQueryable.
If I call an extension method based on a compiled request like GetEntitiesCompiled (). Count () "or" GetEntitiesCompiled (). Take (x) ". What is Linq2Sql doing in the background? That would be very bad, so in this situation I have to write a compiled query like" CountEntitiesCompiled ".
Does it load the result (in this case "GetEntitiesCompiled ()") into memory (mapped to an entity class like "ToList ()")?
So what situations make sense when compiled queries return IQueryable, this query cannot change, before querying Sql-Server. So in my opinion I can just like a good return list.
Thanks for answers!
As I understand it - if it can't use the precompiled query exactly (because you compiled it further), it just runs it like any normal query IQueryable
, so it really will still output SELECT COUNT(1) FROM ...
(it doesn't have to iterate over the entire table / everything) ...
But the real answer: profile; you can hook .Log
to see TSQL like:
myDataContext.Log = Console.Out; // write TSQL to the console
or just use SQL trace to see what goes up and down the wire.
a source to share