Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks for everyone's help so far. A bit more research led me to the NHibernate Burrow project.</p> <p>From the project FAQ (<a href="http://nhforge.org/wikis/burrow/faq.aspx" rel="nofollow noreferrer">http://nhforge.org/wikis/burrow/faq.aspx</a>):</p> <p><em>Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.</em> </p> <p>I had to jump through a few hoops to get it working in my project. Since the current release uses an old version of NHibernate I had to download the <a href="http://nhcontrib.svn.sourceforge.net/viewvc/nhcontrib/trunk/src/NHibernate.Burrow/" rel="nofollow noreferrer">latest source</a> from the trunk, open in VS, add references to latest version of NHibernate and recompile (fortunately no errors).</p> <p>I tested NHibernate Burrow in a number of ways.</p> <p>1) Continue injecting ISession into my repositories</p> <p>To do this, I had to add references to NHibernate, NHibernate.Burrow and NHibernate.Burrow.WebUtil to my MVC project.</p> <p>In web.config I had to set up Burrow (see <a href="http://nhforge.org/wikis/burrow/get-started.aspx" rel="nofollow noreferrer">http://nhforge.org/wikis/burrow/get-started.aspx</a>) and then in my StructureMap registry add the following:</p> <pre><code> For&lt;ISession&gt;() .TheDefault.Is .ConstructedBy(x =&gt; new NHibernate.Burrow.BurrowFramework().GetSession()); </code></pre> <p>I like this approach as it means my repositories (or controllers) are not coupled with Burrow. I don't really like the fact that I have to reference these three assemblies in my web project but at least I lose the code for managing the session - this is all handled by Burrow.</p> <p>2) The second approach would be to set ISession in my repository constructors like so:</p> <pre><code> public ProductRepository() : this(new BurrowFramework().GetSession()) { } public ProductRepository(ISession session) { _session = session; } </code></pre> <p>I can still override ISession making my repositories testable. I then have a direct dependency on Burrow but perhaps this isn't such a bad thing?</p> <p>On the plus side, the only assembly I need to reference from my web project is NHibernate.Burrow.WebUtils.</p> <p>Interested to see which of the two people would go for and why.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload