将 UnitOfWork 与存储库模式结合使用
对 FluentNHibernate 非常陌生,但我也对该领域感到兴奋。我最近开始使用上述内容开发新的 DAL,并一直在阅读存储库模式。我喜欢这种模式所采用的通用形式,并且希望将此模式与 UnitOfWork 模式结合使用来进行会话管理。
我很好奇,这是正确的方向吗?我应该使用 UoW 创建伪单例 NHibernate 会话吗?这个问题实际上是围绕 NHibernate 会话管理的主题展开的。我已经研究过UoW 实现,尽管我我也不清楚我是否应该努力实现这个库,或者抽象我自己的库。
编辑:
只是为了重新澄清问题:
在 FluentNHibernate 环境中使用 UoW 模式和存储库模式是否是常见做法?
Very new to FluentNHibernate, but I'm also excited about the area. I've recently started work on a new DAL using the aforementioned and have been reading up on the Repository pattern. I like the generic form this pattern takes and am looking to use this pattern in conjunction with the UnitOfWork pattern for session management.
I'm curious, is this the right direction to head? Should I be using UoW to create a pseudo-singleton NHibernate session? This question really dances around the topic of NHibernate session management. There is a UoW implementation available that I've taken a look at, although I'm also unclear if I should be working to implement this library, or abstract my own.
EDIT:
Just for re-clarification of the question:
Is it common practice to use the UoW pattern with the Repository pattern in a FluentNHibernate environment?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,要查看一个很好的示例,请查看 FubuMVC-Contrib 的实现 这些。
Yes, for a good example check out FubuMVC-Contrib's implementation of these.
我看到很多“我可以用 Fluent NHibernate 做 X 吗”的问题 - 只是为了澄清 Fluent NHibernate 位于 NHibernate 之上,并为你吐出那些可怕的 XML 映射......它不会影响你能做什么和不能做什么用 NHibernate 来做。
I see a lot of "can I do X with Fluent NHibernate" questions - just to clarify Fluent NHibernate sits on top of NHibernate and spits out those horrible XML mappings for you... it doesn't affect what you can and can't do with NHibernate.