The convention for web applications is that you keep the same ORM context/UnitOfWork during the entire http request. This is in order to work with the same entities during the request, keep the data consistent and minimize the database calls made. The HttpContextScoped
life cycle ensures that the same UoW instance is used during a request for all instances having a dependency on it.
So 1) yes, it's correct
Regarding the rest of the "service layer interfaces", it depends on whether it needs to be the same instance during the entire request. Ask yourself: "will the state of this object be needed during the entire request"? For most "services" this is not the case. Also note that making something "HttpContextScoped" will also make all it's dependencies stay during that scope.
This leads me to say 2) In most cases, no
ReleaseAndDisposeAllHttpScopedObjects
disposes all objects in the container registered with HttpContextScoped
. By default objects are scoped as transient (new instance per call) in Structuremap.
So 3) Just the IUnitOfWork
instance will be disposed.