Created
March 12, 2014 22:08
-
-
Save alistair/9517525 to your computer and use it in GitHub Desktop.
ravendb action behaviour
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 RavenDbBehavior : IActionBehavior | |
{ | |
private readonly IDocumentSession _session; | |
public IActionBehavior InsideBehavior { get; set; } | |
public RavenDbBehavior(IDocumentSession session) | |
{ | |
_session = session; | |
} | |
public void Invoke() | |
{ | |
//You can wrap this in using, but when the nested | |
//container gets disposed, so will the IDocumentSession | |
InsideBehavior.Invoke(); | |
_session.SaveChanges(); | |
} | |
public void InvokePartial() | |
{ | |
//Nothing to do here because we are already inside Invoke() | |
InsideBehavior.InvokePartial(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment