Allow a switch that automatically compiles all queries or allow a simple extension method that compiles queries and stores a hash of the compiled query and returns it if a compiled version of the query exists.
Status: New
|
We do provide compiled queries (see: http://www.mindscapehq.com/documentation/lightspeed/Advanced-Querying-Techniques/Compiled-Queries) and additionally we have automatically generated versions for commonly used patterns which are internally compiled on first call (e.g. FindById or FindAll) to boost subsequent call performance. Is this what you are looking for? If not are you able to elaborate on this?
|
|
|
Hey Jeremy, in EF 5+, all LINQ queries are automatically cached (unless disabled). I'm not sure I'd advocate that as a default behavior, but it would be cool to have an extension method that compiles and then caches the compiled query (say in a static concurrent dictionary) with some kind of hash code. That would make it a lot easier than having to create and store an individual query each time. So something like _unitOfWork.Query CompiledToList() would: 1) Hash the query 2) Check the cache for the query 3) If the query is not cached, compile and cache the query. Automatically create the parameters if the expression contains variables. 4) Execute it with the included param values in the expression Basically it would wrap all the repeated code I'm going to write for each compiled query, of which there will probably be quite a few. I was asking about the anonymous objects because it would have to use these. But if I had access to the internals, I could also possibly cache the anonymous objects with a hash as well. I was thinking about trying to do this myself, but I'm not sure the best way to generate a hash from the query to uniquely identify it. Wasn't sure if a simple "GetHash" would work. Any ideas? Thanks! |
|
|