I wanted to be sure if structuremap will dispose my DataContext after per request ends.
Here is my setup
ForRequestedType().TheD
That's what I do:
For()
.HybridHttpOrThreadLocalScoped()
.Use();
For()
.HybridHttpOrThreadLocalScoped()
.Use(o => ((BpReminders.Data.NH.UnitOfWork)o.GetInstance()).CurrentSession);
and ...
protected void Application_EndRequest(object sender, EventArgs e)
{
ObjectFactory.ReleaseAndDisposeAllHttpScopedObjects();
}
HybridHttpOrThreadLocalScoped uses the HttpContext when available.
StructureMap looks after everything, then. Just remember to implement IDisposable in your classes.