Telerik OpenAccess ORM relies on a naming mechanism that is completely user configurable. This mechanism has some predefined set of rules that are usually enough for the typical scenarios. However if your requirements are not met by the default rules you can easily change the way the name generator works. For the purpose of doing this you will need to edit the xml file that comes with the product.
 |
Current name generator is targeted at supporting English language, but using techniques described in this article one can handle various languages as well. |
 |
The file can be found under [installationfolder]\Telerik\OpenAccess ORM\sdk\IDEIntegrations\templates\PCClassGeneration |
As for now there are two possible customizations that you can do:
- Defining special rules for specific words.
- Adding reserved words.
Defining special rules for specific words
For example: if you want to reverse map a table called Categories than using the default rules the table will be mapped to class named Category. This is because one of the default rules will be applied and change the ‘ies’ to ‘y’. You can however change that. If you add the following to the Rule node in the xml file:
XML |
Copy Code |
<stemming plural=””singular=””/> |
then whenever you perform an action that requires the word Categories to be singularized you will get the word “Cat” as a result (same applies for pluralizing Cat).
Adding reserved words:
If you want to map a specific reserved word to some result nevertheless of the action (pluralizing or singularizing), you achieve this by adding the following item to the xml file:
XML |
Copy Code |
<Rules> <stemming plural="Status" singular="Stat"/> <reserved word=””properMapping=””/> </Rules> |
Now if you try to pluralize the word “name” the result will be “myname”(the same applies if you try to singularize “name”).
 |
The custom rules from the xml file are always applied with precedence to the predefined rules. This means that if you try to pluralize/singularize a word that matches a rule from the xml file and a rule from the predefined rules then the one from the xml file will be respected. |
Using the Inflection rules in different language:
By default the xml file containing the rules is UTF-8 encoded so if you would like to add some words in say Norwegian you will have to tweak it a little bit. What you will have to do is choose the proper encoding. This can be done by adding something similar to this at the start of the XML file:
XML |
Copy Code |
<?xml version="1.0" encoding="ISO-8859-1"?> |