FetchGroups can be defined to describe read access based on concrete usage patterns in the application. The goal here is that only those fields, which are needed by the application, get fetched from the database in as few calls as possible. FetchGroups are used to mark fields and their associated field recursion-depth for each class for which the FetchPlan is applied.
A default fetch group is created for each class, and it will retrieve all the fields that are of basic type or single reference type. In case of reference type fields, only the id of the referenced object is fetched from the database. The referenced object itself will only be fetched when it is actually accessed. Refer to the Default FetchGroup topic for information.
FetchGroups are identified by name and apply to one or more classes. Names have a global scope so the same FetchGroup name can be used for any number of classes. This makes it possible to specify FetchGroups per ObjectScope instead of per class extent. This greatly simplifies the use of FetchGroups in an application.
There are two special FetchGroups:
- FetchPlan.Default - default FetchGroup name definition.
- FetchPlan.All - maximum FetchGroup name definition.
||It is recommended to use symbolic constants for the names of the FetchGroups, for e.g., using the symbolic constant "FG". This avoids problems occurring from misspelled strings and it also structures the usage of FetchGroups more cleanly. |
FetchGroups can be defined by using the Fetch Group Tab of the Forward Mapping Wizard All FetchGroups are defined either in the App.config file or in the source code, by using the [FetchField Attribute]. Use the Options Dialog to specify the location of the fetchgroup definition.