Skip to content

Instantly share code, notes, and snippets.

@alistair
Created March 12, 2014 22:08
Show Gist options
  • Save alistair/9517525 to your computer and use it in GitHub Desktop.
Save alistair/9517525 to your computer and use it in GitHub Desktop.
ravendb action behaviour
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