Click here to Skip to main content
12,508,630 members (37,936 online)
Click here to Skip to main content
Add your own
alternative version


114 bookmarked

Creating DAL Components Using Custom ASP.NET Build Providers And Compiler Techniques

, 24 Oct 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
This article describes how to create Data Access Layer Components (DALC) using ASP.NET build providers and a self-defined description language in C#, including an easy scanner, parser, and CodeDOM generator.


There are many articles on the internet that are dealing with the creation and usage of a Data Access Layer (DAL) and the comprising components, also known as DALC (DAL Components). There is nothing new in the process of creation of a DAL. You can actually use Typed DataSets, Microsoft's Enterprise Library (DAAB), or you may use one of the many third party tools to implement a comprehensive DAL system.

The main objectives of this composition are to show how to create and use ASP.NET build providers and also to explain how easy you can analyze a small self-defined description language to declare DALCs or anything else. To implement a full-blown DAL killer application which you can use for the rest of your programming life is not the objective of this article. Normally, you would not define your own description language to declare DALCs, you would instead use an XML-based description of the components and analyze them using the feature-rich XML classes that come with the .NET framework.

I just wanted to implement a lexical analyzer (a.k.a. scanner or tokenizer), some parsing techniques, and dynamic code generation using the .NET CodeDOM. There are a lot of situations in daily work where it would be handy to develop some kind of parser (even a very small and simple one) to come up with an acceptable and elegant solution. In fact, for one of my customers, I defined a description language to automate the extension of a web application.

To show an example of the final result of a dynamically generated DAL using the DALComp application, let's assume we have a database table called Articles. For this table, the DAL (see section "DALC Description Language" below), respectively, the build provider will automatically create a class called Article, containing private member fields and public properties that correspond to the table column names. Nullable types are created for value types.

In addition, the system generates static methods (also defined within a .dal file) to select the requested data. The data are returned as a generic list of type Article (in C# List


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jürgen Bäurle
Software Developer (Senior)
Germany Germany
I’m a software developer based in Germany.


You may also be interested in...


Comments and Discussions

General:( Pin
Rajesh Kumar Singh Form New Delhi,India5-Dec-13 19:57
memberRajesh Kumar Singh Form New Delhi,India5-Dec-13 19:57 
GeneralMy vote of 5 Pin
Kanasz Robert12-Nov-10 0:34
memberKanasz Robert12-Nov-10 0:34 
GeneralBugz Pin
dojohansen29-Oct-07 4:11
memberdojohansen29-Oct-07 4:11 
GeneralI gave you a five Pin
Ennis Ray Lynch, Jr.25-Jan-07 9:59
memberEnnis Ray Lynch, Jr.25-Jan-07 9:59 
GeneralRe: I gave you a five Pin
Juergen Baeurle25-Jan-07 20:04
memberJuergen Baeurle25-Jan-07 20:04 
QuestionOne Question Pin
Manish Pansiniya15-Dec-06 23:08
memberManish Pansiniya15-Dec-06 23:08 
AnswerRe: One Question Pin
Juergen Baeurle25-Jan-07 20:03
memberJuergen Baeurle25-Jan-07 20:03 
GeneralRe: One Question Pin
Manish Pansiniya26-Jan-07 3:47
memberManish Pansiniya26-Jan-07 3:47 
GeneralRe: One Question Pin
DoVanHung24-Sep-08 21:37
memberDoVanHung24-Sep-08 21:37 
GeneralTrust issues w. build providers Pin
lemz25-Oct-06 5:42
memberlemz25-Oct-06 5:42 
AnswerRe: Trust issues w. build providers Pin
Juergen Baeurle25-Oct-06 5:57
memberJuergen Baeurle25-Oct-06 5:57 
Dear lemz, thanks for providing this information for the readers. Have a nice day. Juergen
GeneralNice Work Pin
Mike Ellison25-Oct-06 4:47
memberMike Ellison25-Oct-06 4:47 
AnswerRe: Nice Work Pin
Juergen Baeurle25-Oct-06 5:06
memberJuergen Baeurle25-Oct-06 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160927.1 | Last Updated 25 Oct 2006
Article Copyright 2006 by Jürgen Bäurle
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid