Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
Created January 4, 2013 11:57
Show Gist options
  • Select an option

  • Save ChrisMcKee/4452084 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisMcKee/4452084 to your computer and use it in GitHub Desktop.
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