活动记录/三层架构
我想将我的应用程序分为三层以使用服务层。 我还想在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用
ActiveRecordMediator
而不是ActiveRecordBase
http://castleproject.org/activerecord/documentation/trunk/advanced/mediator.html
You should use
ActiveRecordMediator<T>
instead ofActiveRecordBase<T>
http://castleproject.org/activerecord/documentation/trunk/advanced/mediator.html