.net core 连接mysql 八:HomeController注入ISysUserRepository

2022/3/27 19:23:35

本文主要是介绍.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 });
}
}
}

 

 

 

 

 



这篇关于.net core 连接mysql 八:HomeController注入ISysUserRepository的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程