使用 Castle ActiveRecord 进行冲洗

发布于 2024-08-03 14:41:25 字数 208 浏览 2 评论 0原文

我看到我可以使用 SessionScope 并插入 在 SessionScope 范围内并在范围末尾执行刷新。

我的问题是我是否可以以某种方式定义之后,让我们 比如说,每 10 次插入/保存对象,它们就会自动 被刷新到数据库。

换句话说,我希望能够配置我使用与城堡活动记录齐平的方式。

ps:有没有办法像 NHibernate 一样为对象配置级联行为?

i saw that i can use SessionScope and have inserts
inside the scope of the SessionScope and do flush at the end of the scope.

my question is if i can define in some way that after, let's
say, every 10 insertions/saves of objects, that they will automatically
be flushed to the db.

in other words i want to be able to configure the way i use flush with castle active record.

p.s: is there any way to configure cascading behavior for objects like in NHibernate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙与沫 2024-08-10 14:41:25

您可以连接自己的 IPostInsertEventListener 来跟踪插入计数并相应地刷新。但我建议不要这样做,除非你有充分的理由这样做。

相关属性有一个 Cascade 属性来设置级联行为。例如,请参阅 HasMany

You could hook up your own IPostInsertEventListener where you keep track of insertion count and flush accordingly. But I recommend against this unless you have some very good reasons to do so.

The relevant attributes have a Cascade property to set cascading behavior. See for example HasMany.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文