I am currently working on including a new functionality for a Website.
I have a DbContext class which I created using EF6.
The website uses a Master Layout in which sublayouts are rendered depeding upon the page requested. I want to use Dependency Injection to access the DbContext in the Sublayouts. Generally, I would use a Controller to handle the calls, however, I want to skip that in this case.
Also, I want to keep the implementation flexible so that new DbContexts are added I will be able to use them easily.
I was thinking of creating an interface "IDbContext".
I will have the new interface(let's say "IRatings") implementing this interface.
Am I going about it the right way?
Any thoughts?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…