活动记录/三层架构

发布于 2024-07-09 07:43:47 字数 257 浏览 8 评论 0原文

我想将我的应用程序分为三层以使用服务层。 我还想在 UI 层和业务层中使用相同的域模型,因为我控制两端。

这是有道理的,但我还想使用 Castles Active Record 作为数据访问层。 因此,我无法再在 UI 中引用域模型,因为 myActive Record 对象(例如“客户和订单”)现在包含直接与数据库通信的逻辑,而不是通过服务层进行通信。

解决这个问题的最佳方法是什么? 有没有简单的方法将活动记录类分为存储库类和哑数据传输对象?

I would like to separate my application into three tiers to use a service layer. I would also like to use the same domain model in both the UI tier, and the business layer tier because I control both ends.

This makes sense, but I would also like to use Castles Active Record for the Data Access layer. Because of this I can not longer reference my domain model in my UI because myActive Record objects eg “Customer and Order” now contain logic which communicates directly the database instead of doing through the service layer.

What’s the best way around this? Is there any easy way to separate the active record classes into repository classes and dumb data transfer objects?

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

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

发布评论

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

评论(1

月竹挽风 2024-07-16 07:43:47

您应该使用 ActiveRecordMediator 而不是 ActiveRecordBase

http://castleproject.org/activerecord/documentation/trunk/advanced/mediator.html

You should use ActiveRecordMediator<T> instead of ActiveRecordBase<T>

http://castleproject.org/activerecord/documentation/trunk/advanced/mediator.html

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