NHibernate 具有多个数据库和事务
我们在理解如何最好地使用 NHibernate 时遇到了一些问题。我们通常拥有相对大量(就表数量而言)的 SQL Server 数据库,而不是一个包含大量对象的数据库。
我们正在研究处理多个会话工厂的各种选项,并且可能已经控制住了这一点。但是,我们不确定如何将所有调用包装在单个事务中。使用手动数据访问,您只需将其全部包装在 TransactionScope 中,但我们有点不愿意使用 NHibernate 这样做,因为它似乎喜欢处理自己的所有事务。
使用具有共享事务的多个数据库似乎是很多人希望使用 NHibernate 做的事情。
我们是不是完全找错了树?
We are having a few problems understanding how best to use NHibernate. We typically have a relatively large number of quite small (in terms of number of tables) SQL Server databases rather than one database with a lot of objects.
We are looking at various options for handling multiple session factories and probably have this under control. However we are not sure how we would wrap all calls in a single transaction. Using hand-rolled data access you would just wrap it all in a TransactionScope but we are a little reluctant to do this with NHibernate as it seems to like to handle all its own Transactions.
Using multiple databases with shared transactions seems like the sort of thing lots of people would want to do with NHibernate.
Are we just barking up the wrong tree entirely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以安全地使用
TransactionScope
。但你也必须打开 NHibernate 事务。例子:
You can safely use
TransactionScope
. But you have to open NHibernate transactions too.Example: