OxyGen Code Generator Overview
Table of Contents
Previous Topic: Publishing the Generated Code
Next Topic: Appendix B – Source Code Component Packages
This appendix describes the processing instruction types and the parameters associated with each processing instruction.
OxyGen supports the following processing instruction types:
The presence of the Cacheable instruction informs the code generation engine that the objects created from the rows in this table should be cached.
Cacheable processing instruction is a parameter-less instruction. The value associated with this instruction is an empty string (the instruction is a processing directive).
At most one Cacheable processing instruction can be assigned to a table.
The presence of the Entity Name instruction informs the code generation engine that the name of the generated entities (in DAL and BL) will be based on the specified Entity Name value, and not the actual table name.
At most one Entity Name processing instruction can be assigned to a table. To avoid name clashing, the values associate to Entity Name processing instructions should be unique at the database level. Also, these values should not be the same as the name of a table that does not have an Entity Name processing instruction.
The Entity Name value should be a valid C# type name. The following restrictions govern the entity name values:
The presence of Reference Type Marker instruction informs the code generator that the generated entity is a lookup entity. Lookup entities are automatically members of the caching system.
Reference Type Marker processing instruction is a parameter-less instruction. The value associated with this instruction is an empty string (the instruction is a processing directive).
At most one Reference Type Marker processing instruction can be assigned to a table.
The Resolve Many To Many processing instruction is used to denote tables whose primary purpose is to breakup Many-To-Many relationships. These tables are created during the de-normalization process to bring the database to the 3rd normal form. This means that the primary tables in this three table system are the initial tables in the Many-to-Many relationship. See “Figure 3: The relationship between the 'Customer', 'CustomerService' and 'ServiceInstance' tables”.
Placing a Resolve Many To Many Processing Instruction against a table tells the code generation engine that you would like to de-normalize this relationship in the generated code. This creates easier access to the data in the two primary tables.
Resolve Many To Many processing instruction is a parameter-less instruction. The value associated with this instruction is an empty string (the instruction is a processing directive).
At most one Resolve Many To Many processing instruction can be assigned to a table.
An example of the usage of the Resolve Many To Many processing instruction is in the model of a Student-to-Class relationship.
One student is member of several classes while one class contains several students. In terms of the physical database, we would have 3 tables to model this relationship: Student, Class and StudentClass.
There is a “One-to-Many” relationship between Student and StudentClass and a “One-to-Many” relationship between Class and SudentClass hence a “many to many” relationship between a Student and a Class. We use the Resolve Many To Many processing instruction to reunite Student and Class in the generated C# code. This also leads to better performance because the Join is handled by a Stored Procedure. The alternative is a double for-loop in C# code.
The Select Processing Instruction allows the developer to specify custom queries.
Multiple Select processing instructions can be assigned to a table/view as long as their parameter sets do not repeat.
The results of using the Select Processing Instruction are the following:
1. A Stored Procedure that uses the specified columns as filter conditions
2. C# methods that require the specified fields (derived from the columns) as parameters. These methods eventually call the above mentioned Stored Procedure and the requested data is returned.
OxyGen Code Generator Overview
Table of Contents
Previous Topic: Publishing the Generated Code
Next Topic: Appendix B – Source Code Component Packages