依赖注入视图view 文件中:
@using MajorEventReportSystem.Data;
@inject EventReportDbContext dbcontext
@{
var systemConfig = dbcontext.SystemConfig.LastOrDefault();
}
<html><head>.....
</html>
https://docs.microsoft.com/zh-cn/aspnet/core/mvc/views/dependency-injection?view=aspnetcore-2.2
发表评论