Wednesday, November 02, 2005

.NET 2.0 Custom Build Providers

Wow this is soooooooo cool I can't believe it!

How would you fancy NOT having to write a DataAccess layer in your apps but instead to get the ASP.NET 2.0 engine to automatically serve the code to you straight from the Database Structure?

If you don't understand the problem, you need to spend a bit more time creating by hand (not allowed to cheat with CodeSmith or other...):

  • Tables
  • Views
  • Stored Procedures
  • .NET Data Access Code that calls everything and performs SELECT, INSERT, UPDATE and DELETE...

Then you will know what I mean especially if your DB has 250 tables, 150 Views and 640 Stored Procedures!!!

I was lucky enough to come across this article from Fritz Onion and I think it is absolutely awesome. Fritz you're a genius man!

Using that idea, I have been able to build a code generator that creates my DataAccess layer automatically from the Database, then in my code I only need to reference the relevant object and call methods against them like:

Dim objProfile as Profile

objProfile.ID = "1"

objProfile.Name = "Test Name"


How cool is that!!!


Anonymous said...

Hi Etienne,

I read your posts as listed below.

I am also having incredibly disastrous problem with my .xsd generated file when I change the database.

Do you have any further info on the topic at all.

And hopefully, more specifically, a setp-by-step procedure for

Thanks in advance.


Etienne Lambert

Etienne said...

Hi there,

I have actually been able to use custom build providers to generate classes automatically, not .xsd files.

I will try and post some procedure on how I managed to accomplish this on my blog asap.

However, if you want to get your teeth into something quite meaty in the meantime, I have noticed on the web that a community of programmers had done exactly the same thing as me in a much better way, have a look at:

It's called subsonic and it's just great... does everything you want out of the box. The complete code base is available in C# and VB.NET. However, it's not writing xsd schemas I don't think, it is automatically generated classes.

Feel free to send me a message with your email if you wish to discuss any further.

Hope this helps,