Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your Domain projects, you define the interfaces for your data acces objects. Your NHibernate persistence project can reference the Domain project and provide implementation for the data access objects. </p> <p>Your service project might reference Domain and <em>not</em> Persistence. Your service objects depend on the data access interfaces in Domain. You use your DI container to wire your service objects to the NHibernate implementations in Persistence.</p> <p>Changing the dependency <code>Domain -&gt; Persistence</code> to <code>Persistence -&gt; Domain</code> is an example of inversion of control.</p> <p>I can imagine you now have the following service:</p> <pre><code>using Persistence; using Domain; public class UserService { private Persistence.NHibernateUserRepository _repository; public UserService (ISession session) { _repository = new Persistence.NHibernateUserRepository(session); // ... } // some service methods } </code></pre> <p>I suggest to change this to:</p> <pre><code>using Domain; // no longer using Persistence package public class UserService { private Domain.IUserRepository _repository; public UserService (Domain.IUserRepository repo) { _repository = repo; // ... } // some service methods } </code></pre> <p>In your StructureMap configuration, you configure an NHibernate Session, which you wire to your <code>Persistence.NHibernateUserRepository</code>. Then you wire your <code>UserService</code> to this <code>Persistence.NHibernateUserRepository</code>. I'm not familiar with StructureMap, so I can't help you with the mechanics. You might want to read:</p> <ul> <li><a href="https://stackoverflow.com/questions/1296901/injecting-isession-into-my-repositories-using-structuremap-in-a-asp-net-mvc-appli">Injecting ISession Into My Repositories Using Structuremap in a Asp.Net MVC Application</a></li> <li><a href="http://www.bengtbe.com/blog/post/2009/02/27/Using-StructureMap-with-the-ASPNET-MVC-framework.aspx" rel="nofollow noreferrer">http://www.bengtbe.com/blog/post/2009/02/27/Using-StructureMap-with-the-ASPNET-MVC-framework.aspx</a> - this is a post that discusses exactly your problem, including StructureMap, NHibernate and asp.net mvc.</li> </ul>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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