First of all this is a great book! I can't wait to read what you write next.
I have been looking for a book like this.
I am following along with the examples in your book.
I have a question about the DataContext lifetime.
I am following your code and looking at
HttpDataContextStorageContainer
and how it uses HttpContext.Current.Items. I understand this is a "Per Http Request" usage.
My question is the DataContext getting properly disposed of and thus database connections getting closed?
In Sql Profiler I am showing some open connections after the Http Request has processed
I have read that the following may need to be used to dispose of the DataContext that stored in the HttpContext
Code:
protected void Application_EndRequest(object sender, EventArgs e)
{
ObjectFactory.ReleaseAndDisposeAllHttpScopedObjects();
}
If the above is needed how does DataContext get setup in the BootStrapper?
Code:
For<IUnitOfWork>().HttpContextScoped().Use<EFUnitOfWork>();
OR
For<MyConcreteDataContext().HybridHttpOrThreadLocalScoped();
Does IDispose need to get implemented anywhere?
FYI: I am using EF 4.1, MS Sql, MVC3, Structure Map
Thanks in advance for any help!