How would you go about registering diferent IDbConnectionFactory instances in Funq and then access them directly within your services? Do named instances somehow come into play here?
Is this the best approach to take when using different databases across services?
Thanks!
EDIT:
An example ;). I could be way off here because I'm pretty new to IoC, but say for example I have 2 separate database connections that I'd like to inject. In ServiceStack, this is done in the Global.asax.
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(@"Connection String 1", SqlServerOrmLiteDialectProvider.Instance));
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(@"Connection String 2", SqlServerOrmLiteDialectProvider.Instance));
Both of these seem to be injected honky dory.
These are then accessed automatically on the service end via something like this:
public IDbConnectionFactory DbFactory { get; set; }
In this case, it seems to be giving me the first one registered. How can I get access to a specific one on the service end? Hopefully that makes it a little more clear.
Here's a full fledged example from ServiceStack.Examples that only uses 1 IDbConnectionFactory: Movies Rest