Need help re-creating Subsonic 2.2 / SubCommander generated table and column names
I am writing some code generation templates that will work hand-in-hand with a SubSonic 2.2 / SubCommander generated classes / assembly. The problem I am having is that SubSo开发者_运维技巧nic is using some beautiful magic to normalize the table and column names, singluarize them, pull out extraneous characters etc..
My generated classes (must) are pulling table and column names directly from the database schema and as you can imagine they do not match subsonic's generated "pretty" names. So I have tried to use several combinations of the Subsonic.Utilites classes, singularize, ToProper, etc... But I cannot seem to find the right combination to match what subcommander is outputting.
I was able to get a copy of the SubCommander 2.0 source code and took a look through there but I did not have luck in fiding where the normalization of names is happening. Could someone help me find the right combination of utility methods that subcommander uses to generate table and column names?
If it makes any difference I am not using any special "switches" for subsonic in my app.config on the subcommander side except for fixPluralClassNames="true".
Take a look at TableSchema.cs, your probably interested in the following two items
The setter for ColumnName in TableColumn class, which calls TransformPropertyName
The setter for TableName in AbstractTableShema class, which calls TransformClassName
There are a few other calls to normalize FK and relationships, but those two above should get your class/property names to match SubSonic.
精彩评论