.net core 连接mysql 八:HomeController注入ISysUserRepository
作者:互联网
using fjxw.echarge.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using fjxw.model;
using fjxw.dal;
namespace fjxw.echarge.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly ISysUserRepository _ISysUserRepository;
public HomeController(ILogger<HomeController> logger, ISysUserRepository SysUserRepository)
{
_logger = logger;
_ISysUserRepository = SysUserRepository;
}
public IActionResult Index()
{
try
{
var userdata = _ISysUserRepository.GetUsers();
}
catch (Exception ex)
{
var errorMsg = ex.Message;
}
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
标签:core,fjxw,System,ISysUserRepository,mysql,using,logger,public 来源: https://www.cnblogs.com/wugh8726254/p/16062245.html