Re: Question about data layer

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




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.


.



Relevant Pages

  • Re: Generics n-tier design question
    ... "GetCustomersWithSpend", then obviously you are going to return customers, ... this is a business layer function ... which in turn will call the data layer. ... > We have stumbled across an issue using the type safe collection ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: n-tier apps - what to use
    ... > GetDataDatareader(string SQL) or DataSet GetDataDatasetand ... > tier and convert a datareader-object to and object of Client. ... Data layer is the only thing communicating with SQL Server, ... > Business layer is using data layer to get data and update data, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Question about data layer
    ... 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.savemethod in the business layer and this method call the person.savemethod in the data layer. ... Those methods could be generateCommandand executeCommand() and the object "person" in the business layer has a savemethod, when you call person.savein the business layer, it call to the methods generateCommandand executeCommandand these methods saves the object "person" in the database. ... 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? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interface question
    ... defines the operations of a data layer, what your business layer is ... "I will work with any data layer that provides the following ... calling implements the interface defined by the business layer, ... the data layer developer can "build to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question about data layer
    ... save, and an object "person" in the business layer, so what I have to do ... call the person.savemethod in the data layer. ... Those methods could be generateCommandand executeCommand() and the ... invoice), and I have to load and invoice by invoice number: ...
    (microsoft.public.dotnet.languages.csharp)