Created
January 4, 2013 11:57
-
-
Save ChrisMcKee/4452084 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public MvcApplication() | |
| { | |
| BeginRequest += delegate { CurrentSessionContext.Bind(SessionFactory.OpenSession()); }; | |
| EndRequest += delegate | |
| { | |
| if (SessionFactory != null && CurrentSessionContext.HasBind(SessionFactory)) | |
| CurrentSessionContext.Unbind(SessionFactory).Dispose(); | |
| }; | |
| } | |
| public static ISessionFactory SessionFactory { get; private set; } | |
| protected void Application_Start() | |
| { | |
| MvcHandler.DisableMvcResponseHeader = true; | |
| SessionFactory = NHibernateHelper.CreateSessionFactory(); | |
| #if DEBUG | |
| NHibernateProfiler.Initialize(); | |
| #endif | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment