Mr
Fri May 02 00:12:54 CDT 2008
"BillE" <belgie@datamti.com> wrote in message
news:O1lDq%238qIHA.4912@TK2MSFTNGP03.phx.gbl...
> I'm trying to decide if it is better to use typed datasets or business
> objects, so I would appreciate any thoughts from someone with more
> experience.
>
> When I use a business object to populate a gridview, for example, I loop
> through a datareader, populating an array list with instances of a custom
> class in the middle tier, and then send the array list up to the
> presentation layer and bind the gridview to it.
>
> If I use a typed dataset, I just fill it with a data adapter and then bind
> it to the gridview.
>
> It seems like the typed dataset would be more efficient, because I don't
> have to loop through anything. But typed datasets are aggravating,
> because it seems like they have to be defined all the way down at the data
> access layer to be accessible in a n-tier solution. They clutter up my
> solution.
>
> Business objects seem tidier, and seem more professional, but are they as
> efficient, with all the looping required?
>
So why can't you just use a Business Object that accesses a DAL object that
brings back the dataset and bind it to the grid's data source? There is
nothing stopping you from doing that. The UI or Presentation tier should not
directly access a database.
There is nothing stopping you from making a DAL object that access a
database table , populate a dataset and return that dataset all the way back
to the UI through the Business Layer and bind the dataset to the control.
As a matter of fact, the UI should totally be unaware of the Business
objects (loosely coupled) UI with the Business Object layer, which is
accomplished with the Presentation layer interfaces that interact with the
Business layer objects. You can send down or bring up things like datasets,
arraylist, strings, List, int. long or whatever through the interface of the
Presentation tier.
What am I talking about?
MODEL-VIEW-PRESENTER
http://www.polymorphicpodcast.com/
click 'Shows'
click 'Design Patterns Bootcamp: Model View * Patterns*
view parts 1-5
But for the example you're presently concerned about, just bring back the
dataset from the DAL to the BUS and bind the dataset to the control.
Busobject bo = new Busobject();
datagrid1,Datasource = bo.GetDataset(); // the DAL returns a dataset to
the BUS and the BUS returns a dataset binds the dataset to the control.