使用dbcontext的.net核心mysql查询

问题描述

如何在使用dbcontext的控制器中执行mySQL查询,其中value是method中的参数。谢谢

查询数据库

 
select MonthName(DateRecord) as Month,count(*) as Employees from database.employees where YEAR(DateRecord) = value Group By Month ;

enter image description here

** employee.controller.cs

此示例是我控制器中的代码

**

  // GET: api/Countries/5
        [HttpGet("{id}")]
        public async Task<ActionResult<Employee>> GetCountry(int id)
        {
            var employee= await _context.Employees.FindAsync(id);

            if (employee== null)
            {
                return NotFound();
            }

            return employee;
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)