Search code examples
.netormcastle-activerecord

Hiding the fact a class is an Active Record


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.


Solution

  • 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.