Sunday, October 24, 2004

DALHelperPlus - New

I recently posted DALHelperPlus.
This is a rebuild of the original DALHelper.aspx developed by Alex Lowe.

The original was appealing in its simple ness - it was a simple aspx page that would list all available stored procedures and it would put together a method that you would just have to paste into your DAL module. No external libraries needed (if you wanted you could choose an option to attach a parameter builder library but it was not the default and not required) All you did was choose your procedure – choose your return type (Dataset/DataReader) – Choose your language (C#/VB) and hit generate – you were done.

I looked at several other generators; most of them required other moving parts for example the stored procedure application block etc… This however was fast efficient and easy to use.

I used to have an instance of ASP.NET web matrix with the page open running in the background and I would just have to alt-tab to get access to it. However my webmatrix install recently got corrupted – and I could not (easily) run it in VS.net. So I decided to port the code over to a (always available) win forms based app.

I started playing with the code and I kept all of the database retrieval and parameter parsing from the original. However the code generation part I redid using the .net CodeDOM. The CodeDOM is a real pain in the neck to program against. It is very verbose and long winded; I almost gave up after 2 or 3 days. But then I found Refly a codeDom wrapper by Jonathan de Halleux that makes codedom programming much easier.

Using the CodeDOM brought another benefit. Where as the original used string building to build 2 different versions for vb.net and c# - here I only had to implement it once using a codedom tree. Further more, the app checks the machine.config file for all available .net compilers and allows you to generate the code for any one of them (you select the language from a drop down). On my machine I have c#,vb.net,javascript.net,J# I am also planning on playing around with Delphi 2005 (Diamodback) when it comes out and I will have a ready made Delphi code generator.

Another key feature of this app is the ability to control where DB connections come from - they can be built from connection strings (global/Local/Embeded/Resource Files) or from code snippets or from connection parameters passed on the command line - this all can be chosen from a drop down box.

You can also specify how you want the return values. Of course there is DataReader and DataSet - but there is also DataTable ,ArrayList (the first column of the resultset), HashTable ( First Column = second column) and primitive types such as int,float bool, (string) which return the first column of the first row typecasted as the appropriate type.

At first the app did not support OUTPUT parameters - that was because Refly did not support ByRef/Ref parameter calling - However a quick email to Jonathan got that fixed and OUTPUT parameters are now supported.

Besides for a desktop application I have also integrated the generation engine as a VS.NET plugin (VS.NET makes it so easy) and the generated code will get written directly to where the caret is in the open document.

You can download the current version (1.1) here.

I am also thinking about opening up a got dot net workspace for this.


Comments:
test
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?