I work though a linq tutorial where the code is written in c# and try to translate the snippets into vb.net. The following is working under c#:
var employeeGroups = from employee in Employee.GetAllEmployees()
group employee by employee.Deptartment;
I could translate it into Extension Method
Dim group1 = Employee.GetAllEmployees.GroupBy(Function(x) x.Department)
which workes fine but
Dim group = From emp In Employee.GetAllEmployees
Group emp By emp.Department
gives me a compile error 'into expected'. I couldnt find anything about it but is it right, that I have to use 'INTO' in vb but not in c#? If so, how do I have to adjust my query to fit the c# aquivalent?
VB.Net has different group syntax. Try this..
From emp In Employee.GetAllEmployees
Group By Department= emp.Department Into g = Group
Select g
Or Simply
From emp In Employee.GetAllEmployees
Group By Department= emp.Department Into Group
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.