【发布时间】:2020-03-20 11:33:32
【问题描述】:
我正在使用 asp.NET MVC。我正在尝试查找员工的薪资等级[正如我们在 oracle 12c 中使用 scott 模式找到的那样]。我创建了 4 个模型 EMP、DEPT、Bonus 和 SalGrade(与 oracle 12c 中的 scott 架构相同)。在 Oracle-12c 中查找成绩的查询如下。
SELECT s.grade, count(*), max(sal)
FROM EMP e, SalGrade s
WHERE e.sal BETWEEN s.LoSal AND s.HiSal
GROUP BY s.grade;
我只需要将上面给出的查询转换为 ASP.NET MVC LINQ 查询。
我创建的模型如下。
部门模型:
public class Department{
[Key]
public int Deptno { get; set; }
public string Dname { get; set; }
public string Loc { get; set; }}
EMP 模型:
public class Employee
{
[Key]
public int Empno { get; set; }
public string Ename { get; set; }
public string Job { get; set; }
public int Mgr { get; set; }
public DateTime Hiredate { get; set; }
public int Sal { get; set; }
public int Comm { get; set; }
public int Deptno { get; set; }
public Department Department { get; set; }
}
SalGrade 模型
public class Salgrade
{
[Key]
public int Grade { get; set; }
public int LoSal { get; set; }
public int HiSal { get; set; }
}
【问题讨论】:
标签: c# asp.net-mvc entity-framework linq