Up Control query execution
DevForce Resource Center » Development guide » Query » Control query execution » Control where the query executes

Control where the query executes

Last modified on August 15, 2012 17:20

DevForce uses the FetchStrategy property of the QueryStrategy class to control where the query executes: in the cache, in the datasource, or in some combination of the two. 

FetchStrategies

Five FetchStrategies  are available in DevForce:

StrategyAction
CacheOnlyApply this query against the cache only, returning references only to entities already there. Do not consult the data source. (Note that this query leaves the cache unchanged.)
DataSourceOnlyRetrieve matching entries from the datasource into the entity cache. Return references only to those entities retrieved from the the data source. A result set returned from a query using this FetchStrategy would not include locally added entities that had not yet been persisted to the data source.
DataSourceThenCache

First retrieve matching entries from the datasource into the entity cache. Discard all references to entities retrieved in this step.

Resubmit the same query against the updated cache. Return references only to entities matched by this second, CacheOnly query.

DataSourceAndCache

First retrieve matching entries from the datasource into the entity cache. Retain references to entities retrieved in this step.

Resubmit the same query as CacheOnly. Combine (union) the references obtained in this second, CacheOnly query with those obtained in the data source retrieval step.

Optimized

Check the query cache to see if the current query has previously been submitted (and, if necessary, inverted) successfully. If so, satisfy the query from the entity cache, and skip the trip to the datasource.

If the query cache contains no query matching or encompassing the current query, then determine if all entities needed to satisfy the query correctly from the cache can be retrieved into the cache. If so, apply the DataSourceThenCache FetchStrategy. Otherwise, apply the DataSourceOnly FetchStrategy.  See the discussion on query inversion for more detail. 

FetchStrategies when the client is disconnected from the data source

If the client is disconnected from the data source, the DataSourceOnly, DataSourceThenCache, and DataSourceAndCache strategies will throw an InvalidOperationException. The Optimized strategy will behave as a CacheOnly query. It will not throw an exception, even if no matching query exists in the query cache.

Created by DevForce on February 18, 2011 17:28

Recently Visited


This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade