0

I'm on a ASP.NET MVC project and I'm using a generic repository on Data Layer.

This app uses 3 differents DataContexts to manage 3 differents databases.

It works great so far.

Now, I'm trying to archieve Unit Of Work and it's working but only if a inject a specific DataContext instance. Is there a way to inject a generic DataContext class and StructureMap instantiates the right DataContext for me?

Thanks!!

André Miranda
  • 6,420
  • 20
  • 70
  • 94

1 Answers1

1

Named Instances are going to be your best bet. Register each context with a name representing the database, then you can resolve the correct DataContext with just a name.

Community
  • 1
  • 1
RyanR
  • 7,728
  • 1
  • 25
  • 39