开发者

I need Linq Query for this SQL Query

开发者 https://www.devze.com 2023-04-09 03:19 出处:网络
\"select count(salary) from employee where employeeID = 10 gro开发者_如何学Goup by salary\" --- Its a SQLQuery.
"select count(salary) from employee where employeeID = 10 gro开发者_如何学Goup by salary" --- Its a SQL  Query.

I need Linq Query which would retrieve me same output..?

Please Help me out i am new to Linq


You should also check :

I need Linq Query for this SQL Query

Full aricle : 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()
              };


Your query puzzles me from the functional perspective: You want to count the number of different salaries for one employee?

Anyway, i think something like this would do also work (untested)

db.Employees.Where(e=>e.id == 10).Select(s=>s.salary).Distinct().Count()
0

精彩评论

暂无评论...
验证码 换一张
取 消