我正在使用 linq教程,其中代码是用c#编写的,并尝试将片段翻译成vb.net.以下是在c#下工作: var employeeGroups = from employee in Employee.GetAllEmployees() group employee by employee.Deptartment; 我可以把它翻译
var employeeGroups = from employee in Employee.GetAllEmployees() group employee by employee.Deptartment;
我可以把它翻译成扩展方法
Dim group1 = Employee.GetAllEmployees.GroupBy(Function(x) x.Department)
工作得很好但是
Dim group = From emp In Employee.GetAllEmployees Group emp By emp.Department
给我一个编译错误’进入预期’.我无法找到任何关于它的信息,但是它是正确的,我必须在vb中使用’INTO’而不是在c#中使用它?如果是这样,我如何调整我的查询以适应c#aquivalent?
VB.Net有不同的组语法.试试这个..From emp In Employee.GetAllEmployees Group By Department= emp.Department Into g = Group Select g
或者简单
From emp In Employee.GetAllEmployees Group By Department= emp.Department Into Group