在带有 Prism 的 MVVM 应用程序中使用 DB4O
我想使用 db4o 在 Prism 应用程序中持久保存我的业务对象。我应该如何维护 IObjectContainer 生命周期?据我从文档中了解到,当我使用一个容器加载对象时,我应该使用同一个容器保存它。所以也许某种单例作用域应该是正确的。但是容器是否会保留对通过它的每个对象的引用,因此是否会导致内存泄漏之类的问题?
我读过一些关于每个业务事务的对话,但它是针对 nHibernate 的,我猜 nHibernate 的会话和 db4o 的容器是完全不同的东西。
可以肯定的是,我正在谈论带有嵌入式 db4o 的桌面应用程序。所以,没有服务器/客户端。
I would like to use db4o for persisting my business object in Prism aplication. How should I maintain IObjectContainer lifetime? As I know from documentation, when I load object with one container I should save it with the same one. So maybe some kind of singleton scope should be right. But doesn't container keep reference to every object which goes through it and because of this doesn't it cause something like memory leak?
I read something about Conversation per Business Transaction, but it was for nHibernate and I guess nHibernate's session and db4o's container are totally different things.
Just for sure, I am talking about desktop application with embedded db4o. So, no server/client.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于桌面应用程序来说,拥有全局容器通常更容易。这样您就可以毫无问题地存储/更新对象。所以单例作用域应该是正确的。
db4o 容器仅保存对对象的弱引用。这意味着它永远不应该阻止对象被收集。
我的桌面应用程序与 db4o 我们有一个对象容器。在每次逻辑操作之后,我们只承诺保留所有更改。
For desktop applications it's usually easier to have a global container. That way you just can store / update objects without any issues. So singleton scope should be the right one.
The db4o container only holds weak references to objects. That means it should never prevent objects from being collected.
I my desktop App with db4o we have a single object container. After each logical operation we just commit to persist all changes.