Created
September 4, 2012 10:08
-
-
Save ayende/3619470 to your computer and use it in GitHub Desktop.
This file contains 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 class RavenController : Controller | |
{ | |
private static IDocumentStore documentStore; | |
public static IDocumentStore DocumentStore | |
{ | |
get | |
{ | |
if(documentStore == null) | |
{ | |
lock(typeof(RavenController)) | |
{ | |
if(documentStore != null) | |
return documentStore; | |
documentStore = new DocumentStore | |
{ | |
Url = "http://localhost:8080", | |
DefaultDatabase = "Nuget" | |
}.Initialize(); | |
} | |
} | |
return documentStore; | |
} | |
} | |
public IDocumentSession DocumentSession { get; set; } | |
protected override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
DocumentSession = DocumentStore.OpenSession(); | |
base.OnActionExecuting(filterContext); | |
} | |
protected override void OnActionExecuted(ActionExecutedContext filterContext) | |
{ | |
using(DocumentSession) | |
{ | |
} | |
base.OnActionExecuted(filterContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment