Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Created November 24, 2012 05:35
Show Gist options
  • Select an option

  • Save bradoyler/4138561 to your computer and use it in GitHub Desktop.

Select an option

Save bradoyler/4138561 to your computer and use it in GitHub Desktop.
RavenDB setup for MVC controller
public IDocumentSession session { get; protected set; }
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
session = MvcApplication.Store.OpenSession();
}
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
if (filterContext.IsChildAction)
return;
using (session)
{
if (filterContext.Exception != null)
return;
if (session != null)
session.SaveChanges();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment