I have IRepository<T> , and implementation SqlRepository<T>. SqlRepository has DataContext parameter in constructor.
SM configuration looks like this:
x.ForRequestedType(typeof(IRepository<>))
.TheDefaultIsConcreteType(typeof(SqlRepository<>));
x.ForRequestedType<DataContext>().CacheBy(InstanceScope.Hybrid)
.TheDefault.Is.ConstructedBy(()=>{
var dc = new FirstDataContext();
dc.Log = new DebuggerWriter();
return dc;
});
But for construction of IRepository<SpecificObject> i want to inject different DataContext. How do I say SM that when I ask for IReposiotry<SpecificObject> I want different DataContext, not FirstDataContext but SecondDataContext (that DC goes to different database).
For example, when I ask for IRepository<T> I want FirstDataContext to be injected, but when I ask explicity for IRepository<Product> I want SecondDataContext to be injected.
Also, that SecondDC should be Hybrid cached by SM!