我正在寻找VB.NET代码来连接2个表来使用LINQ完成Winform的Master Detail。
我在C#中找到了以下代码段。但是VB.NET编译器不喜欢这种语法。
请提供正确的VB.NET代码(我相信INTO
是错误原因):
var matchingEmployees =
from dept in Departments
join emp in Employees on dept.DeptNo equals emp.DeptNo
INTO AvailableEmployees
SELECT NEW { department = dept, employees = AvailableEmployees };
REF:代码项目中的文章“Creating Master Detail representation of data display in Winforms using LINQ (C#)”
答案 0 :(得分:0)
我相信在VB.NET中应该是Group Join
:
Dim matchingEmployees =
From dept In Departments _
Group Join emp In Employees On dept.DeptNo Equals emp.DeptNo _
Into AvailableEmployees = Group _
Select New With {.department = dept, .employees = AvailableEmployees}
参考文献: