Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friend,

I got one sql query which found little bit difficult to convert it into LINQ query.
Query is : How can i write it into Linq query??

SQL
SELECT Emp_Name, sum(salary) as salary FROM [dbo].[Tblmst_Emp1]
GROUP BY Emp_Name
order by Emp_Name Asc
Having Salary > 10000



I google it but didn't find suitable answer..

Thanks..
Posted
Updated 17-Dec-12 0:34am
v2

1 solution

Try this,
C#
var result = (
  from 
    emp 
  in 
    DatabaseContext.Tblmst_Emp1
  where 
    emp.Salary < 10000
  group 
    emp by new { emp.Emp_Name} into e
  select 
    new { e.Key.Emp_Name, Salary = e.Sum(x => x.salary)}
  ).OrderBy(x => x.Emp_Name)
   .toList();


I hope this will help.
Thanks :)
 
Share this answer
 
Comments
Vikas_Shukla_89 17-Dec-12 23:59pm    
Thanx..
Sk. Tajbir 18-Dec-12 1:18am    
no problem :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900