"select count(salary) from employee where employeeID = 10 group by salary" --- Its a SQL Query.
我需要Linq Query来检索相同的输出..?
请帮帮我,我是Linq的新手
答案 0 :(得分:4)
您还应该检查:
完整文章:SQL to LINQ ( Visual Representation )
from e in employee
where e.employeeid=10
group e by e.Salary
into grp
select new
{
Salary = grp.Key,
Count = grp.Count()
};
答案 1 :(得分:0)
您的查询从功能角度来困惑我:您想计算一名员工的不同工资数量吗?
无论如何,我认为这样的事情也会起作用(未经测试)
db.Employees.Where(e=>e.id == 10).Select(s=>s.salary).Distinct().Count()