Using this sample project as a guide, I am creating a new project. My project will follow the same basic architecture, only in addition to the mvc project, I will also have a wcf web service project (or perhaps servicestack.net)
Instead of using Unity for DI, as in the example, I use Ninject. I am currently setting up Ninject as follows to create an instance of only one factory database instance for each web request (and therefore, one datacontext class for each request (using the first EF 4.1 code at the beginning of btw))
kernel.Bind<IDatabaseFactory>()
.To<DatabaseFactory>()
.InScope(ctx => HttpContext.Current);
I am wondering if this method is enough? Or would it be better to let the factory class handle an instance of a datacontext for an HTTP request (and possibly for a stream if I were to design for non-web interfaces in the future)? If so, are there any examples of how to do this?
Or is there a better solution for this?
source
share