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!!!