.net - NHibernate with StructureMap for a Non-Web Application -


For using a standmarkmap for a non-web application, most of the time for injection and handling session / transaction for NIHbernet What's good / P>

In a web context, we use PerRequest session management lifecycle using the hybrid lifecycle of Strikemap, but for a Windows service, I can not control IDisposable UnitOfWork ...

Thank you.

Ayende provides a good summary of how to control NHibernate in the desktop application.

StructureMap, I manually create ISessionFactory manually. After that, declare an example used on all ISessionFactory examples:

  For this & lt; ISessionFactory & gt; (). Use (sessionFactory);  

In this way, you skip the screen to create and remove your sessions. It is important that to avoid memory session, all sessions are separated from each other. This article is explained in full.

With this approach, and with the good use of Ishaalal session according to the need , I've cut several issues in the WPF / StructureMap / NHibernate application.


Comments