使用 Castle ActiveRecord 进行冲洗
我看到我可以使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以连接自己的
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.