I had always had the need in the back of my head to write a Code Generation tool, but could never get around to it. I had found an early open source LLBLGen. I downloaded the code, and started to futz with it before I was forced to work on something else.
About two months ago, I stumbled on CodeSmith. When I saw CodeSmith, I immediately liked that it just wrote code, and left everything else out. LLBLGen is great I am sure, but I don't have the time, patience, and experience to use a complete “O/R Mapper” for my developer businesss of one person. So I got all excited, then forgot all about it once again.
Two weeks ago, I was forced to write some stored procedures that would be perfect to use CodeSmith for, so I decided to try it out. Sure enough, the trial had expired. I uninstalled/reinstalled and it worked. Anyway, I read through the Tutorials, looked through the many sample files, and messed around. It didn't take more than a few hours to have something I could use.
Recently, I needed to start a new project that required some Business Objects. No way was I going to do that by hand anymore. I pulled up CodeSmith, and within 2 – 3 hours, created my template. It worked like a charm.
First you decide what input variables you need. The main one is to select what table(s) you want to generate your code from:
Which will take your template
And turn it into code
I am definately going to poney up the $99 for it. That will allow me to use CodeSmith's UI to write the template files. Without it you are forced to use notepad. Yuck!
By the way, the code generated above is not from tblCustomers, just in case any of you were wondering why there would be a “Contact” field there. And to put it all out on the table, the code is generated from a table I didn't create. Point is, don't flame me!
So I have no created two CodeSmith template files. One to generate the insert, update, select, search, and delete stored procedures for a given table, and the other to generate the business object class and collection. Next I will create one for my .ASPX files and codebehind. And if I don't feel like doing it myself, I can augment an existing template file someone has already done and uploaded to the Template CodeSmith Forum.