If I have a compiled entities query via CompiledQuery.Compile and I then tack on another .Where() clause or .OrderBy() clause, do these addition clauses force a full recompile, a partial recompile, or no recompile?
Does applying additional clauses to a compiled query cause a recompile?
200 Views Asked by Orion Adrian At
3
There are 3 best solutions below
0

All added clauses result in a different query, and therefore a recompile. If you want to be sure you are not doing a recompile, finish the call to the query with a .AsEnumerable()
or .ToList()
. This materializes the query, and after that you can do all the ordering etc. you want.
As per your request, see this msdn article.
With the compiled query
called like this:
the output is like this
The only conclusion is that there is no recompile, but the
.Where(el=>el.ErrorMessage.Contains("foo"))
is applied with LINQ2Objects on the objects resulting from the LINQ2SQL query.