简体   繁体   中英

Using UnitOfWork with the Repository Pattern

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?

是的,作为一个很好的例子,请查看FubuMVC-Contrib的这些实现

我看到很多“我可以用Fluent NHibernate进行X处理”的问题-只是为了说明Fluent NHibernate位于NHibernate之上,为您吐出那些可怕的XML映射...这不会影响您可以做什么,不能做什么用NHibernate做。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM