How can I use my IoC container in a DataService
and the CurrentDataSource
inside for WCF Data Services? I have several services I want to pass into it. The "host" application or project for the DataService
is based on ASP.NET MVC 2.0. My IoC container is setup in the MvcApplication
.
views:
39answers:
1
A:
This is not as "clean" as integrating your IoC container deep into the WCF factory classes but if you want to supply a DataSource you could use the Common Service Locator (link at bottom) with your existing IoC container and override the CreateDataSource method of DataService
protected override MyEntityContext CreateDataSource()
{
return ServiceLocator.Current.GetInstance<MyEntityContext>();
}
Common Service Locator library