CodeSmith is becoming really useful

We have a couple of dozen objects that get passed around in XML, and need to be stored in the database. We've written a base class to do the grunt work, but at some point, each item in the XML needs to be mapped to a parameter in a stored procedure. We started with all the database tables, and all the XML schemas, but nothing in between. There are various artifacts that need producing to get the process working from end to end.

Once the first XML to database process was finished, I used each of the major artifacts as the basis for a CodeSmith template. Using these templates, I was able to generate the next set in the time it took my colleague to work out why TeamTest was crashing when testing something using the Enterprise Library (i.e. a couple of hours).

The templates generate:
  1. A stored procedure to insert a row into the table
  2. A TSqlUnit test for this stored procedure
  3. A class derived from the base class that sets up the correct configuration file
  4. A unit test class that checks this class
  5. A stored procedure used by this unit test
  6. The basis of the mapper file
  7. The extra lines to put in the database installer script
The XPath must still be pasted into the mapper file, but this takes only five minutes, and can't be automated. This step actually needs some kind of analysis; the rest is just routine stuff that we don't need to spend time on.
29 June 2005