我正在使用Castle ActiveRecord,但是将它包装在我自己的持久层中,因为我想从应用程序代码中隐藏这个事实。 但是,我的实体都继承自ActiveRecordBase<T> ,因此我选择的ORM泄露给应用程序。 我特别不喜欢的是暴露我的实体的一系列方法。
如何在不继承ActiveRecordBase的情况下使用ActiveRecord?
我知道抽象的某些部分会泄漏,因为我的实体用ActiveRecord属性修饰,但我不认为这部分有意义。
I'm using Castle ActiveRecord, but wrapping it in my own persistence layer, because I want to hide this fact from application code. However, my entities all inherit from ActiveRecordBase<T>, so my choice of ORM is leaking to the application. What I especially don't like is the slew of methods this exposes off my entities.
How can I use ActiveRecord without inheriting from ActiveRecordBase?
I know some part of the abstraction will leak because my entities are decorated with ActiveRecord attributes, however I don't consider this part meaningful.
最满意答案
使用Castle ActiveRecord时,您的实体不必从基类继承。 您可以使用ActiveRecordMediator<T> 。 也许本手册中的这篇文章会有所帮助。
When using Castle ActiveRecord your entities do not have to inherit from the base class. You can use ActiveRecordMediator<T> instead. Perhaps this article from the manual will help.
更多推荐
发布评论