Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get WCF-StructureMap-NHibernate to work together?
    text
    copied!<p>Can anyone point me to an up to date example of how to integrate all 3 of these tools? I have found some examples but they seem out dated. Here are the examples that I have found.</p> <p><a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/09/16/integrating-structuremap-and-nhibernate-with-wcf.aspx" rel="nofollow">http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/09/16/integrating-structuremap-and-nhibernate-with-wcf.aspx</a><br> <a href="http://andreasohlund.net/2009/04/27/unitofwork-in-wcf-using-structuremap/" rel="nofollow">http://andreasohlund.net/2009/04/27/unitofwork-in-wcf-using-structuremap/</a> &lt;-- Doesn't address nhibernate<br> <a href="http://blog.coreycoogan.com/2010/05/26/structuremap-wcf-nhibernate-part-1/" rel="nofollow">http://blog.coreycoogan.com/2010/05/26/structuremap-wcf-nhibernate-part-1/</a><br> <a href="http://blog.coreycoogan.com/2010/05/27/structuremap-wcf-nhibernate-part-2/" rel="nofollow">http://blog.coreycoogan.com/2010/05/27/structuremap-wcf-nhibernate-part-2/</a> </p> <p>I started trying the coreycoogan example, but I ran into a few issues. He shows creating StructureMap registry where a dependency is injected into the constructor of the Registry, but he doesn't show how to do that part. I have never seen that example with StructureMap registries. All of the examples that I have seen have a parameterless contstructor.</p> <p>Is this possible, if so how? I am making a call to the ObjectFactory.Initialize method in a Bootstrapper class that makes a call to the scanner with default conventions and a call the LookForRegistries method. This finds all of Registry classes except for the one that needs the dependency injected. I would assume since I don't have it wired in correctly or it is not possible.</p> <p>Here is small part of that code example for the registry that is in part 2 of his post:</p> <pre><code>/// &lt;summary&gt; /// A StructureMap registry for telling the container how to resolve an ISession request. /// This must be instantiated and added to the SM configuration so it has an instance of the /// SessionFactory to use. /// &lt;/summary&gt; public class WcfNHibernateRegistry : Registry { public WcfNHibernateRegistry(ISessionFactory sessionFactory) { For&lt;NHibernate.ISession&gt;() .Use(() =&gt; sessionFactory.GetCurrentSession()); } } </code></pre>
 

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