|3.5 C# and VB
Visual Studio Version:
The Telerik Data Access implementation of the Contains
IQueryable extension method uses the limits of the backend for maximum number of IN values
and maximum number of query parameters
to smartly switch
between using IN clause
or Temporary Tables
for the filtering on the backend side. These projects show how to influence the behavior of Contains in order to force it to always use IN clause
and handle scenarios where the size of the in memory collection used for the filtering is beyond the said limits of the backend. This will be useful in cases where you need to finely tune the performance of your LINQ queries using Contains or your application does not have the required privileges to create Temporary Tables. The following steps are taken in the creation of the projects:
- Expose the BackendInformation object for your model as shown here.
- Save the original values of the MaximumNumberOfInValues and MaximumNumberOfQueryParameters properties.
- Set the values of the MaximumNumberOfInValues and MaximumNumberOfQueryParameters properties to be higher than both the original limits and the size of the in memory collection against which Contains will be used.
- This will prevent the usage of Temporary Tables. Instead a DataStoreException will be thrown when the actual backend limits are hit.
- To handle situations where the size of the in memory collection used for the filtering goes beyond the actual backend limits, the collection is partitioned to chunks small enough to satisfy the limits.
- As the limits set through BackendInformation affect the behavior of every existing and future instance of OpenAccessContext, the original values of the limits are restored.