Skip to content

Instantly share code, notes, and snippets.

@codereflection
Created March 7, 2011 22:41
Show Gist options
  • Select an option

  • Save codereflection/859420 to your computer and use it in GitHub Desktop.

Select an option

Save codereflection/859420 to your computer and use it in GitHub Desktop.
NHibernate Unit of Work management with ASP.NET MVC
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
var manager = IoC.Container.GetService<IUnitOfWorkManager>();
manager.Begin();
}
protected void Application_EndRequest(object sender, EventArgs e)
{
var manager = IoC.Container.GetService<IUnitOfWorkManager>();
if (manager == null)
return;
manager.Commit();
manager.Complete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment