DAL/BL设计问题

发布于 2024-10-08 08:15:30 字数 254 浏览 0 评论 0原文

我正在开发 .net 2.0 Windows 应用程序。 数据访问层[DAL]执行存储过程并将数据读取器/数据集返回给业务层[BL]。

BL引用DAL dll,迭代数据读取器/数据集,读取列值,创建业务对象并将其返回给UI层。

鉴于此,业务层在这里引用数据库表的列可以吗?

这是层设计的好做法吗?

如果我从DAL而不是数据集/数据读取器返回业务对象,那么我的DAL项目也必须引用BL dll。那么,这里不会有循环引用吗? 谢谢。

Am working on a .net 2.0 windows application.
The data access layer[DAL] executes stored procs and returns datareader/dataset to the business layer[BL].

The BL which refers to DAL dll, iterates through the datareader/dataset, reads columns values, creates business objects and returns it to the UI layer.

Given this, is it ok here that the business layer is referring to columns of a database table?

Is this a good practice wrt layer design?

If I return Business object from the DAL instead of dataset/datareader, then my DAL project will have to refer to BL dll too.So,wont there be a circular reference here?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断舍离 2024-10-15 08:15:30

这不是一个好的做法,因为您的数据层暴露了实现细节,因此信息隐藏和封装丢失了。

您应该传递对数据进行建模的对象。

例如,您应该传递 Order 对象,而不是 order 数据行。

It is not good practice, as your data layer is exposing implementation details and thus information hiding and encapsulation are lost.

You should be passing objects that model your data.

For example, instead of an order data row, you should be passing an Order object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文