"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 :
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()
精彩评论