This example demonstrates how to use a single query to retrieve fields from different databases by using
FetchPlans and
FetchGroups.
It retrieves all orders and fetches the
CompanyName and
LastName for each Customer.
By default, such operation would require the execution of more queries
as data would be retrieved from several tables, but by using
Telerik OpenAccess ORM you can include the required related fields in a fetch
group and retrieve the records in a single query.
FetchPlans and
FetchGroups provide you with a mechanism where you can specify the retrieval of only those fields that are required from the database in as few database calls as possible.
Thus you could optimize the queries executed by OpenAccess ORM when retrieving more complex data. A default
FetchGroup is created for each class, and it retrieves all fields that are of basic type or a single reference type (where only the id of the referenced object is retrieved), as a result of a query or while resolving a reference.
Telerik OpenAccess ORM allows you to specify fetch groups in a visual way from a "Forward Mapping" dialog available in Visual Studio. You do not need to change your queries (OQL or LINQ) and put information about
your fetch groups, which makes things easier for maintenance.