Hi All,
I've been looking over a few posts regarding different issues and customisation requests, and I think I may have something that could be worked into a solution. I'm thinking that we could probably used the MS_Description for individual columns and/or tables, either combined with the mapping.config file or by themselves, to affect the code generation to incorporate more "custom" features.
For example, take the 4 requests / suggestions / issues below:
1. Localization: http://community.codesmithtools.com/forums/t/7191.aspx
2. Oracle NUMBER vs Int32, Single, Double, Decimal: http://community.codesmithtools.com/forums/t/6971.aspx
3. Overriding the text for edit control labels: http://community.codesmithtools.com/forums/p/7002/26684.aspx#26684
4. Specifying/Handling/Ignoring readonly columns: http://community.codesmithtools.com/forums/p/2004/8256.aspx#8256
I'm thinking we could come up with some simple format for adding this control data to the Description fields for columns and/or tables, and use that control data to influence how the code is generated.
For example, maybe the MS_Description for a column could be set to something like this:
DataType=Decimal;FriendlyName=Amount;ReadOnly=true
During parsing of the database and column description, this string could be split appropriately, and a hashtable of key/value combinations created. Other parts of the code could check for appropriate keys, and generate code depending on the values.
This should work for the column description field in Oracle as well, giving us a way to forcibly specify the .NET datatype we want to use for an Oracle NUMBER column.
The example above should be pretty clear. Imagine we have an Oracle table of invoices, with an INVOICE_ORIGINAL column of datatype NUMBER. The above string would force .netTiers to generate this as a Decimal datatype, using "Amount" as the FriendlyName (pumped to mapping.config?), and the ReadOnly=true means the column would be included in SELECTs, but not in UPDATEs, and create the on-screen representation of that field as read-only.
It would be easier to keep this stuff in sync if it was in the database rather than a separate mapping file, and there's also the possibility of using the fields in database documentation tools as well, to enhance the documentation process.
I think the important thing would be a agree on a format for the Description field (SQL Server, Oracle or whatever). I've used semi-colon delimited key/value pairs in the example above ... someone else might have a different / better idea. Maybe a shorthand XML format?
Any comments? Has something like this already been implemented, and I've missed it? :-D
T