creating DAL, how????

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hey

ASP.NET 2.0

I'm designing the DAL (Data Access Layer) of my web application. I want
every table to have a strongly typed object as wrapper arround the table. So
that for example if the DAL found 3 records in the table then it sends a
generic collection of 3 objects to the BLL (Business Logic Layer).

But here is the problem:
What if I need to do a select like this (combining data from multiple
tables):
select field_1, field_2, field_3 from table_1, table_2

As far as I know I cannot just use the table wrapper as I mentioned above on
this select, because some of the fields are from a different table. Should I
just create a new strongly typed object for this select or could I use the
wrapper objects I mentioned above, or what do you suggest????

Jeff
 
I'm designing the DAL (Data Access Layer) of my web application. I want
every table to have a strongly typed object as wrapper arround the table.
So that for example if the DAL found 3 records in the table then it sends
a generic collection of 3 objects to the BLL (Business Logic Layer).

But here is the problem:
What if I need to do a select like this (combining data from multiple
tables):
select field_1, field_2, field_3 from table_1, table_2

As far as I know I cannot just use the table wrapper as I mentioned above
on this select, because some of the fields are from a different table.
Should I just create a new strongly typed object for this select or could
I use the wrapper objects I mentioned above, or what do you suggest????

You've hit the nail on the head...

Opinions vary on this, but it's my opinion that a DAL should be as light as
possible and should UNDER NO CIRCUMSTANCES make reference to individual
databases or tables. If you do this, every time you modify your schema,
you'll need to modify your DAL! My DAL is based very closely on the
Microsoft DAAB and, being so, means that it can be dropped into any VS.NET
project (WinForms or WebForms) with absolutely no modification whatever.

From your description it sounds very much as though your DAL is more of a
mixture / combination of business layer and data abstraction layer - I'd
strongly urge you to rethink this...
 
Thank you for that great tip about Microsoft DAAB, I didn't know about it.
I've googled and came across some articles which I will read of the subject.
If you have any great links about DAAL, maybe you could post some of them
here?
 
If you want to do the kind of ORM classes that you refer to, you'll need to
use one of the frameworks that generates "wrapper" classes that provide for
things like programmatic Joins. I know there are some CodeSmith templates
that can generate this type of code, but frankly, unless you really know what
you are doing the learning curve to get there could be pretty steep.
Peter
 
You've hit the nail on the head...

Opinions vary on this, but it's my opinion that a DAL should be as light as
possible and should UNDER NO CIRCUMSTANCES make reference to individual
databases or tables. If you do this, every time you modify your schema,
you'll need to modify your DAL! My DAL is based very closely on the
Microsoft DAAB and, being so, means that it can be dropped into any VS.NET
project (WinForms or WebForms) with absolutely no modification whatever.

From your description it sounds very much as though your DAL is more of a
mixture / combination of business layer and data abstraction layer - I'd
strongly urge you to rethink this...

A DAL can be based on the DAAB, but a DAL is not the DAAB

Of course, if you don't have the separated machines or multiple DBs it
make no sense to make an application complicated by DAL...
 
Of course, if you don't have the separated machines or multiple DBs it
make no sense to make an application complicated by DAL...

Indeed! An application should be simplified, not complicated, by a DAL...
 
Yeah, DAL is not the DAAB... I thought it was the same, but that was before
I had read some of the articles I came across on internet about DAAB
 
ORM classes? -> what is ORM acronym for?


Peter Bromberg said:
If you want to do the kind of ORM classes that you refer to, you'll need
to
use one of the frameworks that generates "wrapper" classes that provide
for
things like programmatic Joins. I know there are some CodeSmith templates
that can generate this type of code, but frankly, unless you really know
what
you are doing the learning curve to get there could be pretty steep.
Peter
 
Yeah, DAL is not the DAAB... I thought it was the same, but that was
before I had read some of the articles I came across on internet about
DAAB

Sounds like you're heading in the right direction... :-)
 
Good point.

The website I'm developing (it's a hobby project) is using a database which
have the database on the same computer and the database is the standard SQL
Express which is installed by VS2005.....

One reason for using DAL/BLL is that I'm not sure about what database site
will be hosted on (maybe the hoster has mysql, maybe it is mssql 200...)...
Though I haven't decided on which hoster to use... I just thought it could
be a good idea to let the site be configurationable...

I'm not sure I need to use DAL/BLL but are doing it for developing my skills
in DAL/BLL design.. get my hands dirty in working with DAL/BLL could be good
for me... just in case I some day comes on a development project and need to
use my DAL/BLL skills
 
Hi Jeff,

As a best practice I think it's good take a look at myGeneration /
doodads, also they have some few other dal architectures you can look
at.
 
Back
Top