Data Access Layers (DAL) on the .NET framework

A Data Access Layer, commonly referred to as a “DAL” is code that provides the ability to view, edit, update and otherwise manipulate persistent data within an application. In many cases, a DAL can be generated from a database schema and alleviates developers from the task of writing highly repetitive code. All of the DAL’s I’ve looked at have benefits and detractors so the task of actually selecting the perfect implementation isn’t straight forward and will depend on the application requirements as well as the developers ability work with the given DAL implementation.

There are lot’s of DAL implementations available like:  

There are many others but the above list represents ones I’ve either experimented with or actually used with the one exception being CLSA.NET which I’ve seen mentioned in numerous places and thus why included it.

A few months ago SPOIL implementation in particular caught my eye and seems quite interesting. In fact, I did some digging on this one and found that a BorCon speaker Steve Scott presented the same idea at BorCon 2003 and even before that Atif Aziz had developed DBMethods though there is no mention of it in the MSDN article (referenced above) but I did find an interesting comment from Atif. For a website I’ve been working on over the past few years I chose to use CodeSmith 2.6 which is a freeware code generator specifically for it’s “collection of database templates” which are included in the download. These templates provide several pieces of the DAL puzzle including:

  • Stored Procedure generation for all CRUD operations
  • Command wrappers for the above stored procs
  • Typed datasets
  • Business Objects
  • Typed collections

Of course, lots of things have changed since I made my choice, CodeSmith is up to version 4.0 and now sold commercially and AFAICT garnered quite a following not to mention .NET 2.0 was new at the time and there wasn’t a whole lot of support for it. Additionally, the templates were subsequently updated to utilize C# 2.0 features like generics. CodeSmith is an easy to use code generation tool that has an interesting template technology that borrows techniques from ASP.NET. I’ll admit it took me awhile to convince myself that I needed to go this route at all but eventually I was satisfied with the decision. I’d have probably gone in a different direction today though I don’t really feel locked into the decision I made since the code is fairly boiler plate and it wouldn’t be that difficult to switch to another DAL.

A couple of months ago I spent quite a bit of time looking into Adapdev and it’s supporting tools Codus, a code generator and Zanebug a unit testing tool. It’s really a nice combination and allows you to quickly generate a DAL and immediately test it allowing you to quickly locate problems. The developer Sean McCormack has been very responsive to bugs and even quickly turned around a fix for a significant problem I had run into. Unfortunately, he has recently blogged about a slowdown in the development though I think it’s still well worth a look.

I don’t want to ramble on too long so I’ll wrap it up by saying that I’ve had some good success finding very useful DAL implementations though I have yet to find one that has really addressed all of my needs. If you’ve been doing similar work I’d be interested to know what’s worked for you.

Update: Paul Hectors made the comment that CSLA.NET is a Business Object framework and not a DAL implementation. He’s right. Here is a link that explains what CSLA.NET is from the author himself. Thanks for the correction Paul.

[UPDATED: April 25, 2008] Related post:

12 thoughts on “Data Access Layers (DAL) on the .NET framework

  1. Hi Steve,
    I would just like to make you aware that I would not class as a DAL. It is a mobile/business objects framework and declares abstract methods for persistence where it is up to the user to use the DAL of preference.
    Best regards,

  2. Hi Paul,
    Good point. I had debated a different title for this entry which included mentioning Business Objects as they are frequently coupled with a DAL. Dan Miser originally mentioned CLSA.NET to me a long time ago and including it here was probably not the best idea.
    Thanks again for pointing this out and I’ll update this entry to clarify things.

  3. Hey Steve! Thanks for the kind words regarding Codus and my other Adapdev projects. FYI, I plan on kicking things back into high speed come January…I even have some new stuff that I’ll be releasing. So, just bear with me as I catch my breath a little. 🙂 Development will definitely continue.
    Have a great day!

  4. Hi Sean,
    Great news! I’ve still got my eye on Adapdev and Codus though I myself haven’t had the time necessary to really get moving on it. I’m hoping either over the holidays or after the first of the year I’ll get back into it again.

  5. I heard of an excellent product that was created by a company formerly named Borland, now CodeGear. <shaking his head>
    I love your support for Open Source and similar products, but I wonder why you did not mention ECO as it is much more powerful than most of the products you mention here.

  6. Yes, Steve good article, but where is ECO, it has many features that the product in this articles don’t have, I think the ECO is to main reason to keep with CodeGear, becouse I don´t see any product like ECO
    to visual studio
    kind regards

  7. Hi Holger & Frank,
    The requirements of a project I was working on for a client included availability of source code and use of stored procedures which precluded the use of ECO. The project was unrelated to my work at Borland however I feel the information is valuble and thus worth sharing.

  8. Good news about Adapadev. You know where Sean lives, don’t you, Steve? 🙂
    I’m starting a new project on a handheld, and will keep you in the loop on any good data libraries I come across.

Comments are closed.