Unity, LINQ to SQL, and Implicitly Sharing a DataContext

Feb 16, 2009 at 12:22 PM
I'm currently using Unity and LINQ to SQL on a project and have a need to share a LINQ to SQL DataContext between two services in the presentation layer. So far, we've managed to keep the DataContext out of the presentation layer, and we'd like to keep it out. I know I could register a DataContext in a child container explicitly, but can I somehow implicitly register a DataContext that can be shared between two services? If not, I think registering a factory method might work, but I'd love to somehow inject a shared DataContext for all services.
Oct 28, 2009 at 7:33 PM

Sorry, this isn't supported in Unity 1.2. You'll need to go the child container route.


Oct 28, 2009 at 11:40 PM

See this thread where I outlined at LifeManager that we used to solve this very problem


Oct 29, 2009 at 1:49 AM

That's excellent! Thanks, rslaney!