我开始学习ASP.NET 5(vNext)中的变化,但是找不到如何获取IServiceProvider,例如在“Model”的方法中。
我知道,我们在启动时配置服务,但是所有的服务集合都在哪里或者IServiceProvider?
public class Entity
{
public void DoSomething()
{
// This next line doesn't compile.
// Where is ServiceContainer or something like that?
var dbContext = ServiceContainer.GetService<DataContext>();
}
}
我知道,我们在启动时配置服务,但是所有的服务集合都在哪里或者IServiceProvider?
ASP.NET 5
中不起作用,而这正是 OP 关注的。也许我漏掉了什么? - Serj Sagan