Wednesday, April 21, 2004
CodeSmith and my DAL
My original thought was to write a template for CodeSmith that would generate wrapper methods around all my stored procedures. I've been rethinking this approach, although I'm not sure exactly what I'm going to do.
Anyway...I've been working on the CodeSmith template and I have a good start. For each stored procedure in my database, I'm creating a method within a class named 'StoredProcedures'. This class lives in my DataAccess namespace. I have my 'insert' wrappers returning an integer value (my insert stored procs return @@identity). My "select" wrappers return DataTables. Updates and Deletes return void. I'll probably include exception handlers in all of the methods.
The cool thing about CodeSmith is that you can write methods that are callable from within the template. For example, I have a method that returns the "return type" for my method based on the type of stored procedure that's being called. I've got another method that returns my C# parameter list based on the parameters the stored procedure requires.
The biggest complaint I have so far with CodeSmith (I'm using the trial version of CodeSmith Studio) is the amount of time it takes to compile/generate the output. Of course, the system I'm using to test CodeSmith (and to write this blog) is an old P-II 400. My laptop (a P-III 1.7 gHz) is sitting on my desk, but that would mean leaning forward to type. :-)
I'm also tempted to change the template so that it doesn't automatically process every stored procedure in the database. I may change it so a single proc is processed. If I want to process them all, I'll create a config file and run CodeSmith from the command-line.
you can also discontinuation our lately [url=http://freecasinogames2010.webs.com]casino[/url] box loath of at http://freecasinogames2010.webs.com and be the champion in de jure in clover !
another voguish [url=http://www.ttittancasino.com]casino spiele[/url] in the sector of is www.ttittancasino.com , because german gamblers, bloomer in unconstrained online casino bonus.