Data Access has been discontinued. Please refer to this page for more information.

FetchStrategy Class

The FetchStrategy class provides immediate loading and filtering of related data. You could specify a FetchStrategy per context and per query.

General

When you query for an object, you actually retrieve only the object you have requested. The related objects are not automatically fetched at the same time. The FetchStrategy class provides one method which helps you to achieve immediate loading of specified related data. The LoadWith method allows immediate loading of data related to the main target. The MaxFetchDepth property determines how "deep" into the object graph to traverse when loading an instance. For example, with a MaxFetchDepth of 2, Telerik Data Access will load at most the target instance and its immediate relations. With MaxFetchDepth of 3, Telerik Data Access may load the target instance, its immediate relations, and the relations of those relations. The value of the MaxFetchDepth must be greater than 0 and the default one is 3. The maximum possible value depends on the database server and the class hierarchy depth and is bound by the number of SQL joins required. The MaxResultsLimit property can be used for performance optimizations, when not all of the instances matching the query are required. This property limits the maximum number of instances to be returned by a query execution.

Examples

When you retrieve Customers from the Northwind sample database, you can use the FetchStrategy to specify that Orders will also be retrieved. You can even specify which subset of Orders to be retrieved.

Consider the following topics, which are entirely dedicated to the Telerik Data Access FetchPlans API: