Martijn Veken


Just having
some fun with .NET

MyGeneration experiences

I've been reading some of Patrick Wellink's posts about MyGeneration with dOOdads and I was curious if the productivity claims he was making are really true. Because the application that I'm currently working on already has a complete DAL in place, this was not a good candidate to try it on (I don't think I would have made it out of the office alive ;-). But one of my personal web sites was a perfect candidate to try it on.

Last year I promised some of my friends that I would build a web site for the Formula 1 competition we were having. Before every race we would e-mail our forecasts for the race and some pour fellow would calculate the results manually. I said that I could easliy build a web site for this, but I forgot to do so until 3 weeks before the start of the season. So, I "developed" the site under some time stress, created an Access database, dragged and dropped some dataconnectors on the forms and bound the controls to them. It worked and looked rather nice from the outside, but is was far from perfect.

First I used the Access upgrading wizard to migrate the tables and data to SQL Server 2005 Express and translated some of the queries that I had build to SQL views. For the dOOdads architecture to work, you will need to create some extra stored procedures in the database. I used the "SQL_StoredProcs.vbgen" template in MyGeneration, selected the tables I wanted the procedures generated for, and after a couple of seconds the script was ready and I ran it on the database.

After this I used MyGeneration with the "CSharp_SQL_dOOdads_BusinessEntity.vbgen" template to create the data access classes, which I added to my project. These classes are impletented as abstracts so you will have to write concrete classes to implement them. Or ofcourse, generate them with the "CSharp_SQL_dOOdads_ConcreteClass.vbgen" template (you will have to add an using directive to this template to the namespace that you have used to generated the data access objects).

The last generation step is to create objects for the views in the database using the "CSharp_SQL_dOOdads_View.vbgen" template. These are implemented in concrete classes already.

To make all of theses classes work, you will have to add the MyGeneration.dOOdads project to your solution. Don't forget to set the "Build Action" property to compile for SQLClientEntity and the SQLDynamicQuery classes. Build the solution and you're ready.

It took me about 30 minutes to do this, but if you've done this before, you can do it in 5. Converting the rest of the application was very easy. The dynamic query feature of the dOOdads lets you create strong typed dynamic queries with great ease and loads them into the business objects. The objects have a DefaultView property that you can use as a datasource for your controls.

Other nice features of the dOOdads architecture are:

  • String properties: these are string equivalents of the fields of your objects, that make the handling of null values easy by converting them from and to empty strings.
  • Prevention of SQL-injection attacks.
  • Easy transaction handling

For a good impression of all the dOOdads features read this introduction document.

MyGeneration and the dOOdads architecture make it really easy to create a useful solid DAL for your application. There are also a lot of other templates available for MyGeneration on their site. Creating your own templates will be a bit harder. The IDE has no intellisense and you will have to build your scripts in a sort of ASP.

Comments

Patrick Wellink said:

Nice to see that all my effort to promote dOOdads has some effect.

Success !

Patrick Wellink
# May 16, 2006 3:38 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Please add 8 and 3 and type the answer here: