Re: Question about data layer
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Tue, 26 May 2009 12:57:14 -0400
As my blog points out. I prefer to have the DAL return
IDataReader(s)
DataSets (normally strong DataSets)
Scalars (Count(*) of a table would be an example)
voids (for updates, inserts, deletes when you don't need feedback)
The BAL will use the DAL....get the IDataReader.....consume it, then get rid
of it as soon as possible.
Because the DAL returns IDataReader(s), the DAL can be "switched" out to
another RDBMS with no effect on the BAL. IIRC, that was the point.
I also prefer Controller(or Manager) classes....in the BAL. Ex:
CustomerController.
The controller allows you to maintain the proper granularity on how much
data you serialize.
Ex: You have Customers, Orders, OrderDetails.
Sometimes you just want a list of Customers, and you don't want their Orders
(and OrderDetails).
Sometimes you want the whole shooting match, Customers,Orders and
OrderDetails.
Instead of having the business object make this decision (or passing "flags"
to it)...... the Controller controls granularity.
Also, if you serialize (WCF for instance) a bunch of Customer
objects.....you keep the objects very small.............
When you pass alot of data over the wire, you pay very close attention to
this.
.........................
If you're interested in multiple RDBMS support with the same BAL code, pay
attention to this blog entry specifically:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry
Start there and work your way up. LINQ throws some wrenches in the plans as
well. But save that for another day.
<someone@xxxxxxxxxxxxx> wrote in message
news:%23hr2$vh3JHA.1712@xxxxxxxxxxxxxxxxxxxxxxx
Thanks a lot for your quick answer!
Regards,
Marcelo.
sloan escribió:
You need to read this article:
http://msdn.microsoft.com/en-us/library/ms978496.aspx
bookmark it.
read it today
read it tomorrow
read it next week
read it a month from now
read it 6 months from now
You will develop a deeper understanding with each reading ~and after
you've tried some stuff.
........
You can download some code here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!139.entry
for my sample project. I picked one of the implementations suggested at
the MS article.
http://sholliday.spaces.live.com/feed.rss
Go there, I have a 2.0 version of the above URL.
<someone@xxxxxxxxxxxxx> wrote in message
news:%23K5pLoh3JHA.5816@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have two C# beginer questions.
What's the best way to store an object (as an example, person) in the
database?
Option 1 - Having in the data layer an object "person" with a method
save(), and an object "person" in the business layer, so what I have to
do is to call the person.save() method in the business layer and this
method call the person.save() method in the data layer.
Or...
Option 2 - Having a DAL class with generics methods for all objects.
Those methods could be generateCommand() and executeCommand() and the
object "person" in the business layer has a save() method, when you call
person.save() in the business layer, it call to the methods
generateCommand() (to create the SQL sentence) and executeCommand() (to
execute the SQL sentence) and these methods saves the object "person" in
the database.
I saw it in both ways so I don't know what's best.
Another question:
If I have in the data layer two objects: Header and Detail (part of
invoice), and I have to load and invoice by invoice number: Who is in
charge for loading these two objects? or where do I have to do the load?
data layer? how?
In advance thanks a lot for any help.
Regards,
Marcelo.
.
- Follow-Ups:
- Re: Question about data layer
- From: Paul
- Re: Question about data layer
- From: someone@xxxxxxxxxxxxx
- Re: Question about data layer
- References:
- Question about data layer
- From: someone@xxxxxxxxxxxxx
- Re: Question about data layer
- From: sloan
- Re: Question about data layer
- From: someone@xxxxxxxxxxxxx
- Question about data layer
- Prev by Date: Re: Question about data layer
- Next by Date: Re: Question about data layer
- Previous by thread: Re: Question about data layer
- Next by thread: Re: Question about data layer
- Index(es):
Relevant Pages
|