Quick Objects Documentation Akal Tech Logo
Generating Business Logic Layer Classes From Database Schema

Glossary Item Box

This tutorial will walk you through each step of creating your own business logic layer classes using the Quick Objects Designer application.

Quick Objects Designer application can be used to retreive the database schema from either Oracle or SQL Server database. The schema information can then be used to modify and specify Quick Objects Framework related properties. Then this information can be saved in a project file which can be opened later for modification or code generation.

Lets start by creating a blank project in Visual Studio (or IDE of your choice). This project can be either a class library, WinForms, Web Application project or a WebServices project. Essentially any project type that you can create and use classes in! We suggest creating a class library but it is completely up to you to decide how you would like to organize your code and classes.

Let us start the Quick Objects Designer program (Available under the Start -> All Programs -> Akal Tech - Quick Objects V2 menu).

 


EnlargeClick to enlarge

 

From the Settings menu choose the "Manage Connections" menu item and now you will see the following screen.

 


EnlargeClick to enlarge

This form lets you add/modify database connections for the databases you would like to create applications for. In our case we will be connecting to the QO_SHOP database on the SQL Server Express instance. Clicking on Add New button will open another dialog that will let you enter a Name and the connection string for your database.

In our case we are going to use the QO_SHOP as the name and the appropriate connection string.

 


EnlargeClick to enlarge

After entering the Name and Connection String values click the OK button. Now we will test the connection to ensure the provided connection string actually works. Choose the appropriate database type from the "Choose database type" drop down, in our case it is SQL Server 2005. Then click on the Test button and you will get a message indicating that the connection string works or not.

 


EnlargeClick to enlarge

Click OK button to save your newly created connection.

 

Now it is time for us to create a new project by loading the QO_SHOP database schema from the database server. Click on the Projects menu and then choose Load From Database.

 


EnlargeClick to enlarge

 

Now lets choose the QO_SHOP connection string we saved earlier, and click on the OK button. This should load the database schema into the environment.

 


EnlargeClick to enlarge

 


EnlargeClick to enlarge

Now simply right click in the Tables list and then click on "Select All" option. This will check all the tables in the List, it will also check all the fields on all the tables. If you do not want a table to be included just uncheck it.

 


EnlargeClick to enlarge

 


EnlargeClick to enlarge

 

Now lets specify the Project properties. Project properties are located in a Tab on the right side. If you click on the Project Properties tab you will see a screen like the ones below. 


EnlargeClick to enlarge
 

EnlargeClick to enlarge
The two tabs called Files Path and Options as seen above contain various settings that you can specify to customize the code generated by this application. In files path section you have the ability to specify the one folder for your base classes and another folder for custom classes. We recommend that you generate both the very first time, but on revisions only generate the base classes. This way you can create any custom code or override the functionality offered by base classes and retain your changes even after code generation. With .NET 2.0 you have another option i.e. you can create your code in a different file altogether and use the partial keyword in the class definition. This is very useful as you can regenerate all the classes and your custom functionality is always preserved in separate files.
File Paths
Custom Class Files Output Path: This path is used as the path where custom class files will be generated.
Base Class Files Output Path: This path is used as the path where base class files will be generated. This path may or may not be the same as the path for the Custom Class files.
Custom Template for Classes: This can be used to specify a custom template for custom classes (optional). This is not necessary but provided as an option in case you create a custom template as per your needs.
Custom Template for Base Classes: This can be used to specify a custom template for base classes (optional). This is not necessary but provided as an option in case you create a custom template as per your needs.
Options
Namespace: All the generated classes will be inside this Namespace.
Author Name: This name will appear in the comments at the top of each generated class file.
Modification Date: If you choose Auto as the option, then the current date time value will be used in the comments. Otherwise you can choose a date of your choice.
Parent Objects Postfix: All the related (parent) objects (based on related tables that have a parent relationship) will have this value added at the end of their name.
Child Objects Postfix: All the related (child) objects (based on related tables that have a child relationship) will have this value added at the end of their name.
Base Classes Postfix: This value will be added at the end of each class's name to create the base classes.
Make Class Name First Letter Uppercase: If this is checked, all generated class names' first letter will be upper case and the rest of the letters will be in lower case.
Naming Convention For Related Object Properties:

This drop down has three choices: FieldName_RelatedTableName, RelatedTableName, ConstraintName.

  • FieldName_RelatedTableName is very good choice if your database has complex relationships. There may be more than one relationship between 2 tables, or self referencing relationships etc. This convention ensures that each unique relationship is assigned a unique name (one that actually makes sense when you see it).
  • RelatedTableName is a good choice if your database has simply relationship and does not contain any self referencing relationships and any combination of two tables don't have more than one relationship between them.
  • ConstraintName is a goo choice if you clearly defined your constraint names in your database. If you relied on any tool or database to generate these names for you while creating relationships the chances are very high that the ConstraintName values may or may not make sense.
Prefix For Join Methods: This value is used as a prefix when creating helper methods that let you create joins between various objects. The methods are named in this manner: JoinPrefixValue_FieldName_RelatedTableName or if you selected RelatedTableName in the naming convention the generated method name will be JoinPrefixValue_RelatedTableName.
Generate Documentation: This includes Summary xml tags inside your class files.
Source Code Target Version: If you will be using the code in .NET 1.1 then only use .NET 1.1 as your option. However if you will be using the code in .NET 2.0 you can use either of the options. However code generated with .NET 2.0 option is not compatible with .NET 1.1 as the code will generate attributes that were not part of .NET 1.1 framework.
 
It is now time to save your project before generating the classes.
 

EnlargeClick to enlarge
 
Once you have saved the project, you can reopen it anytime and work on it or use it to generate class files.

EnlargeClick to enlarge