This is the first post of the series that have the goal to help Telerik OpenAccess ORM users enhance their experience in Linq against OpenAccess persistent objects.
The two areas where performance enhancement can be taken advantage of are reusing a Linq query from the query cache and altering the query in a way where bigger portions of it are executed on the server. Today we will share with you a tip about the first one.
When a Linq query is requested for execution, the query goes through a step of compilation – where the Linq query expression tree is transformed to an SQL expression tree. After that step is completed Telerik OpenAccess ORM uses the query cache to keep the already compiled Linq queries, so it can reuse them for further execution.
How can we take advantage of this? There are countless scenarios where two queries are very similar but are used for completely different purposes in an application. For
Another module of the
Although very similar, these queries generate different expression trees. That always leads to two compilation steps. This is the moment where little refactoring should be done and parametrized queries used. Consider the following method:
When this method is called twice, once per application module, you guessed – compilation of the Linq query is performed only ones. The
There are numerous queries that can be used as example from the Telerik OpenAccess ORM 101 Linq Samples available in the Telerik OpenAccess ORM code-library.
Subscribe to be the first to get our expert-written articles and tutorials for developers!