设计DAL/数据集/业务对象 [英] Design DAL/DataSet/Business Objects

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

问题描述

我当前正在设计一个需要访问数据库(SQL Server)的应用程序(.Net WinForms).

使用数据源向导,Visual Studio自动为行创建数据集,表和类:

例如,如果我有客户"表,则向导将创建"CustomersRow"类,该类继承自Global.System.Data.DataRow,并将相应的字段作为属性.

在我的应用程序中,我需要为Customer类实现其他方法和属性.

如何处理这些生成的类,如何通过添加方法来对其进行修改..或忽略它们并实现我自己的业务类?

第二个问题:

如何填充我的对象(例如客户列表?)

您是建议使用数据表/数据集及其方法,还是建立自己的数据访问层并满足客户列表(客户)?

我在搜索网络时发现了一些模式,但这并不精确.

感谢

I am currently designing an application (.Net WinForms) that needs to access a database (SQL Server).

Using the datasource wizard, Visual Studio automatically creates the dataset, tables and classes for rows:

For example if I have the Customers table the wizard will create "CustomersRow" class that inherits from Global.System.Data.DataRow with the corresponding fields as properties.

In my application I need to implement other methods and attributes for the Customers class.

How to deal with these generated classes, modify them by adding methods.. or ignoring them and implement my own business classes?

A second question:

How to populate my objects (eg list of customers?)

Do you suggest using datatables / dataset and their methods or build my own data access layer and I meet the client list (of customers)?

I found some patterns when searching the net but it is not precise.

Thanks

推荐答案

在MSDN上有完整的开发N-Tier Apps的演练. http://msdn.microsoft.com/en-us/library/bb384398.aspx [ ^ ]

在如何做"中的C#和VB开发人员区域中,还有一些出色的视频,覆盖数据部分和其他一些部分.
There is a complete walkthrough of developing N-Tier Apps over at MSDN; http://msdn.microsoft.com/en-us/library/bb384398.aspx[^]

There are also some excellent videos in both the C# and VB developer areas in the ''How Do I'', forms over data sections and some of the other sections.


我建​​议创建您自己的实体"对象和数据访问层"以填充它们[域模型].

微软当然为Dataset等提供了很好的支持,但是它似乎已经脱离了表模型的编程风格,例如Silverlight中没有Dataset.

这将为您带来更多的工作,但确实会在需要时为您提供更多的操作和更改技术的空间.

我不建议将数据访问代码放入您的实体中(有些人更喜欢这样,因为它们全部放在一个地方),但是更喜欢从外部对实体的填充进行外部化,并保留实体以进行纯数据传输.
I would recommend creating your own "entity" objects and "data access layer" to populate them [Domain Model].

Microsoft certainly offers very good support for Datasets etc. but it seems to be moving away from Table Model style of programming, for example there is no Datasets in Silverlight.

This entails more work for you, but does give you more room to maneuver and change technologies when the need arises.

I would not recommend putting the data access code inside your entities (some prefer this as it is all in one place), but prefer externalizing the filling of entities from outside and keeping entities for pure data transfer.


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

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