grouping by more than 1 column
-
hi all, Can any1 help me as to how to group by more than 1 column using LINQ.Ive succeeded grouping with 1 column as follows. DC1DataContext dc = new DC1DataContext(); var Fetch = from e in dc.employee join d in dc.dept on e.emp_ID equals d.emp_ID group e by e.emp_ID into g select new { EmpID = g.Key, Total= g.Count(), }; now i want to group by empname also..this is my original query select e.emp_id,emp_name,count(*) as total from employee e ,dept d where e.emp_id = d.emp_id group by e.emp_id,emp_name Thanx in advance
T.Balaji
-
hi all, Can any1 help me as to how to group by more than 1 column using LINQ.Ive succeeded grouping with 1 column as follows. DC1DataContext dc = new DC1DataContext(); var Fetch = from e in dc.employee join d in dc.dept on e.emp_ID equals d.emp_ID group e by e.emp_ID into g select new { EmpID = g.Key, Total= g.Count(), }; now i want to group by empname also..this is my original query select e.emp_id,emp_name,count(*) as total from employee e ,dept d where e.emp_id = d.emp_id group by e.emp_id,emp_name Thanx in advance
T.Balaji
hi all, i got the solution.. we shud give like this.. var Fetch = from e in dc.employee join d in dc.dept on e.emp_ID equals d.emp_ID group e by new {e.emp_ID,e.empname} into g select new { EmpID = g.Key.emp_ID, Empname= g.key.empname, Total= g.Count() };
T.Balaji