2. More About the Object Relational Model
* Customized Load Methods
<< * Customized Business Logic   |   Back to Main   |   * Optimistic Locking >>

View Source
will open in a new window
Implementing a Customized LoadBy or LoadArrayBy
(Note: for more information about creating custom queries, please refer to Section 3 of the Examples Site.)

With the InstantiateDbResult method that is code generated for you in each generated class, it is very simple to create your own custom LoadBy or LoadArrayBy method using your own custom SQL. Simply specify a custom Load query by using Qcodo Query (or by writing your own SQL statement and passing the results into InstantiateDbResult). The code generated logic will take care of the rest, transforming your DB result into an array of that object.

In our example below, we have a custom load function to get an array of all Project objects where the budget is over a given amount. We pass this amount as a parameter to LoadArrayByBudgetMinimum.

Load an Array of Projects Where the Budget >= $8,000

• ACME Website1 (Budget: $9560)
• State College HR Sxzxxystem (Budget: $80500)