隐藏一个类是Active Record的事实(Hiding the fact a class is an Active Record)

编程入门 行业动态 更新时间:2024-10-24 23:19:30
隐藏一个类是Active Record的事实(Hiding the fact a class is an Active Record)

我正在使用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.

更多推荐

本文发布于:2023-08-02 21:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1381513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事实   Record   Active   class   fact

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!