使用LINQ在Winform中掌握详细信息

时间:2014-02-16 02:22:33

标签: vb.net linq master-detail

我正在寻找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#)

1 个答案:

答案 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}

参考文献: