键入的数据集与业务对象 [英] typed datasets vs. business objects

查看:51
本文介绍了键入的数据集与业务对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试决定使用类型化数据集或商业

对象是否更好,所以我很感激来自有更多

经验的人的任何想法。


例如,当我使用业务对象填充gridview时,我通过datareader循环

,使用自定义实例填充数组列表

中间层的类,然后将数组列表发送到

表示层并将gridview绑定到它。


如果我使用类型化数据集,我只需用数据适配器填充它然后将它绑定到gridview。


看起来类似于数据集会更有效率,因为我不会b / b
必须循环通过任何东西。但是类型化的数据集正在恶化,因为它似乎必须在数据访问中一直定义它们才能在n层解决方案中访问
层。它们使我的解决方案变得混乱。


业务对象看起来更整洁,看起来更专业,但它们是否有效,并且需要所有循环?


谢谢

比尔

解决方案



BillE < be **** @ datamti.comwrote in message

news:O1 **************** @ TK2MSFTNGP03.phx.gbl ...


我正在尝试决定使用类型化数据集或商业

对象是否更好,所以我很感激某人的任何想法更多

体验。


当我使用业务对象填充gridview时,我循环

通过datareader,在中间层填充一个带有自定义

类实例的数组列表,然后将数组列表发送到

表示层并将gridview绑定到它。


如果我使用类型化的数据集,我只需用数据适配器填充它,然后将它b / b
绑定到gridview。


看起来类型化的数据集会更有效率,因为我不需要
必须循环通过任何东西。但是类型化的数据集正在恶化,因为看起来他们必须在数据中一直定义

访问层才能在n层解决方案中访问。它们使我的

解决方案变得混乱。


业务对象看起来更整洁,看起来更专业,但它们是否有效,需要所有循环?



那么为什么你不能只使用一个访问DAL对象的业务对象

带回来数据集并将其绑定到网格的数据源?

没有什么能阻止你做这件事。 UI或表示层不应该直接访问数据库。


没有什么能阻止你制作访问
$的DAL对象b $ b数据库表,填充数据集并通过业务层将数据集一直返回到UI,并将数据集绑定到控件。


事实上,UI应该完全没有意识到业务对象层的业务

对象(松散耦合)UI,这是用b / b完成的


业务层对象交互的表示层接口。您可以发送或发送数据集,

arraylist,strings,List,int等内容。很长或者通过

表现层的界面。


我在说什么?


MODEL -VIEW-PRESENTER

http://www.polymorphicpodcast.com/


点击''显示''


点击''Design Patterns Bootcamp:Model View * Patterns *


查看部件1-5


但是对于您目前关注的示例,只需从中恢复

数据集DAL到BUS并将数据集绑定到控件。


Busobject bo = new Busobject();


datagrid1,Datasource = bo .GetDataset(); // DAL将数据集返回到总线,并且BUS返回数据集将数据集绑定到控件。





" BillE" < be **** @ datamti.comwrote in message

news:O1 **************** @ TK2MSFTNGP03.phx.gbl ...


我正在尝试决定使用类型化数据集或商业

对象是否更好,所以我很感激某人的任何想法更多

体验。


当我使用业务对象填充gridview时,我循环

通过datareader,在中间层填充一个带有自定义

类实例的数组列表,然后将数组列表发送到

表示层并将gridview绑定到它。


如果我使用类型化的数据集,我只需用数据适配器填充它,然后将它b / b
绑定到gridview。


看起来类型化的数据集会更有效率,因为我不需要
必须循环通过任何东西。但是类型化的数据集正在恶化,因为看起来他们必须在数据中一直定义

访问层才能在n层解决方案中访问。它们使我的

解决方案变得混乱。


业务对象看起来更整洁,看起来更专业,但它们是否有效,需要所有循环吗?


谢谢

Bill



我确定幕后数据集无论如何都要循环通过....除了

这就是电脑做什么,它们循环......我不会为此担心...


我绝不是大师。因为我只有真正经验丰富的数据集,但是我已经做了很多很多很多阅读,而不是自定义对象。所有

我的研究几乎可以通过以下方式得到满足;数据集对于小型项目来说非常好,但是大型和/或复杂的项目他们只需要b $ b b b b b b b .... .... ... ... .... ... ... ... ... ...定制

对象。


我目前的项目基于数据集及其在某些方面的常规,但

后来在赛道上变成了一个真正的痛苦。


我为获取数据集而做的工作量太多了。 ...每次数据库

更改时,拖拽并将内容放到xsd上.... ugg ...所以即时尝试生成它们并不是一件容易的事......我是/>
希望我们已经去了自定义业务对象......但是我还没有去过那里

所以我不能告诉你....但那就是所有事情都指向......


我也喜欢整洁....它意味着更快更易读的代码...它的价值

很多......数据集绝不是整洁的:(


希望有所帮助

John Sheppard




" John Sheppard" < sp ** @nospam.com写信息

news:fv ********* @ news2.newsguy.com ...


>

" BillE" < be **** @ datamti.comwrote in message

news:O1 **************** @ TK2MSFTNGP03.phx.gbl ...


>我正在尝试决定使用类型化数据集或商业
对象是否更好,所以我很感激来自更多人的想法
经验。

当我使用业务对象填充gridview时,我通过datareader循环
,用自定义实例填充数组列表中间层的类,然后将数组列表发送到
表示层并将gridview绑定到它。

如果我使用类型化数据集,我只需填写一个数据适配器,然后将它绑定到gridview。

似乎类型化的数据集会更有效,因为我不必循环任何东西。但是类型化数据集正在恶化,因为它们似乎必须在数据访问层一直定义才能在n层解决方案中访问。它们混乱了我的解决方案。

业务对象看起来更整洁,看起来更专业,但它们是否高效,需要所有循环?

谢谢
比尔



无论如何,我确定幕后数据集循环遍历....除了

那是什么计算机做,他们循环......我不会为此担心...


我绝不是一个大师。因为我只有真正经验丰富的数据集,但是我已经做了很多很多很多阅读,而不是自定义对象。所有

我的研究几乎可以通过以下方式得到满足;数据集对于小型项目来说非常适合,但是大型和/或复杂的项目他们只需要让你保持优势......所以对于大型项目来说,值得设置

自定义对象。


我目前的项目是基于数据集及其在某些方面的常规,

但它会去后来在赛道上变成了一个真正的痛苦。


我为获取数据集而做的工作量太多了。 ...每次数据库

更改时,拖拽并将内容放到xsd上.... ugg ...所以即时尝试生成它们并不是一件容易的事......我是/>
希望我们已经去了自定义业务对象......但是我还没有去过那里

所以我不能告诉你....但那就是所有事情都指向......


我也喜欢整洁....这意味着更快更易读的代码...它的价值

很多...数据集绝不是整齐的:(



为什么这个人需要定制业务o在将数据绑定到控件的情况下,在
对象的Arraylist中出现?如果数据集仅以前向方式使用
,那么简单地将数据集绑定到

控件是一个更清洁,更快速的解决方案。


我想和你谈谈大项目中使用的数据集。我在一个使用内部书面目标代码生成器的客户端站点上工作


指向基于仅使用存储过程的SQL,以及所有内容

是使用DAL中的数据表和数据集生成的。 DAL由

Windows桌面,Windows服务和Web应用程序使用,在大型项目中也使用了




数据集只是内存中数据的表示。这就是全部,并且在DAL中使用的
数据集与在DAL中使用未使用数据集的自定义对象一样快且可行的解决方案和数据表,

仍然可以自定义使用DAL数据库的DAL代码

引擎。


它'在上面的示例中使用UI中的数据集和数据表是错误的

。应该从UI中提取数据库访问权限,以便

不会遇到您面临或将要面对大型项目的问题。


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?

Thanks
Bill

解决方案


"BillE" <be****@datamti.comwrote in message
news:O1****************@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.





"BillE" <be****@datamti.comwrote in message
news:O1****************@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?

Thanks
Bill

Im sure behind the scenes datasets loop through things anyway....besides
thats what computers do, they loop...I wouldnt worry to much about that...

I''m by no means a guru. As I have only really experienced datasets, but I
have done lots and lots and lots of reading on them vs custom objects. All
my research can pretty much be sumed up with the following ; Datasets are
excellent for small projects but large and/or complicated projects they just
keep you hemmed in....so for big project it''s worth the setup of custom
objects.

My current project is based on datasets and its groovy in some regards, but
its going to become a real pain in the butt later down the track.

The amount of work I have done to just get my datasets generated has been
too much....Draggin and dropping stuff on to xsd every time the DB
changes....ugg...so im trying to generate them and its no easy task.....I
wish we had of gone custom business objects...but then I havent been there
so I cant tell you....but thats where everything points...

I like neat also....it means quicker more readable code...its worth
alot...datasets are by no means neat :(

Hope that helps
John Sheppard



"John Sheppard" <sp**@nospam.comwrote in message
news:fv*********@news2.newsguy.com...

>
"BillE" <be****@datamti.comwrote in message
news:O1****************@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?

Thanks
Bill


Im sure behind the scenes datasets loop through things anyway....besides
thats what computers do, they loop...I wouldnt worry to much about that...

I''m by no means a guru. As I have only really experienced datasets, but I
have done lots and lots and lots of reading on them vs custom objects. All
my research can pretty much be sumed up with the following ; Datasets are
excellent for small projects but large and/or complicated projects they
just keep you hemmed in....so for big project it''s worth the setup of
custom objects.

My current project is based on datasets and its groovy in some regards,
but its going to become a real pain in the butt later down the track.

The amount of work I have done to just get my datasets generated has been
too much....Draggin and dropping stuff on to xsd every time the DB
changes....ugg...so im trying to generate them and its no easy task.....I
wish we had of gone custom business objects...but then I havent been there
so I cant tell you....but thats where everything points...

I like neat also....it means quicker more readable code...its worth
alot...datasets are by no means neat :(

Why does this person need a custom business object in an Arraylist of
objects in the case of binding data to a control? If the dataset is being
used in a forward only manner, then simply binding the dataset to the
control is a much cleaner and faster solution.

And I beg to differ with you about a dataset being used in big projects. I
worked at a client site that used an in-house written object code generator
that pointed to SQL based on using stored procedures only, and everything
was generated using datatables and datasets in the DAL. The DAL was used by
Windows Desktop, Windows Service and Web applications, which was also used
in large projects.

A dataset is just a representation of data in memory. That''s all it is, and
datasets used in a DAL is just as fast and a viable solution than using
custom objects at the DAL that are not using datasets and datatables, which
one could still customize the code of the DAL that used the DAL database
engine.

It''s a mistake using datasets and datatables in the UI in your example
above. The database access should have been extracted from the UI so that
one doesn''t face the problems that you are facing or will face for large
projects.


这篇关于键入的数据集与业务对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆