Using LLBLGEN (Open Source) to generate your DAL Part 1
page 1 of 1
Published: 10 Nov 2003
Unedited - Community Contributed
Abstract
Review of LLBLGEN with an initial examination of other competing technologies.
by Eric Landes
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 6076/ 10

Using LLBLGen to generate your DAL (Part 1)

Why use a DAL?

In my quest to do as little repetitive coding as possible, I ran across this little free gem,LLBLGEN from the folks at Solutions Design http://www.sd.nl/software/default.asp.LLBLGen can be used to quickly generate standard DAL methods. Steve Smith who runs AspAlliance, first mentioned this on a listserve I used and I had to check it out.

Why use a data access layer? As a standard part of the Microsoft n-tier strategy, using a data access layer (sometimes called data services layer) should be part of your .NET development strategy. This article on MSDN about 3 tier application architecture http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cossdk/htm/pgdesigningapplications_9lik.asp explains the reasoning behind having a data access layer.

I use a DAL for a variety of reasons. As a way to encourage encapsulation of code, more robust error handling, a way to encourage word peace. Okay, maybe not the last reason, but it also makes operations like inserts, deletes, updates, and selects simple to invoke in my client modules. With the code generation of LLBLGEN and others, I can also rapidly develop my applications.

This article and the following Part 2, goes over the benefits of using a data access layer, and a full overview of using LLBLGen. There is a brief overview of two alternative methods as well, which may turn into a Part 3 and 4 depending on my schedule.

Technical Requirements

This article assumes that you are using ASP.NET, Microsoft SQL Server 2000 (including SQL Query Analyzer and the Northwind DB), and Visual Basic .NET or C#.You must also download and install the LLBLGEN software from http://www.sd.nl/software/default.asp.

Benefits of creating your data access layer.

There are many benefits to creating a data access layer. It does sound cool saying DAL at your presentation for the User Group. Also, it conforms to the Microsoft standards shown in our earlier link.

Obviously, if you are already working to encapsulate your codeMaintainability of code forms a second benefit. Developers maintaining the code can easily follow the established patterns of the DAL to create custom access methods.

Reusability is another benefit for using a DAL. Let’s say I have created a method to retrieve all the states using an object that access our states table in an SQL Server database. For instance, let’s say I have created a class called cls_States, with a method called selectall that returns a datatable. I can then bind that to a datagrid or listbox.

VB Code Sample:

1:     Dim myStates as new cls_States
2: Mydatagrid.datasource = myStates.SelectAll
3: Mydatagrid.databind


C# Code Sample:

1:     cls_States myStates = new cls_States();
2: DataGrid1.DataSource=myStates.selectAll;
3: DataGrid1.DataBind;


And of course, if I include a reference to this Projects dll in future projects, I can retrieve the States by similar statements. This enables you to create a useful library of functions that are reused a lot.

Methods of creating your DAL

Roll your own.

Before I utilized LLBLGEN, I created my own data access layer.I used the the tool Microsoft Data Application Blocks (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp) to handle connecting and executing basic SQL Server commands and returning bindable data. This eliminated my manually setting up an SQLConnection object, SQL Command, applying the parameters and error trapping.

Even though Data Application Blocks took care of a lot of the mundane tasks to create a datareader, or dataset, you still had to program updates, inserts, deletes, and selects. You also had to create stored procedures for each of these taks. Most of these operations are similar no matter what table you are performing these actions on. While this method has no additional cost other than my time, I wanted more!

Deklarit.

Deklarit is a full fledged Rapid Aapplication Development tool option to generate your business objects.Using a drag and drop style GUI, Deklarit allows you to model your business objects, then it generates the DAL based on your modeling. It even generates administration forms based on your models.


Sample Deklarit Screen.

This article focuses on LLBLGen, so I’ll leave a full blown article on Deklarit for later. With all this power, Deklarit does come with a price tag. It costs $499 - $899 per license. Check their site www.deklarit.com.

Next, Part II, Using LLBLGen to create your DAL



User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 5:49:05 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search