0

I am looking for VB.NET code to join 2 tables to complete Master Detail for Winform using LINQ.

I found the following code snippet in C#. However VB.NET compiler does not like this syntax.

Please kindly provide me correct VB.NET code (I believe INTO is the error cause):

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: Article "Creating Master Detail representation of data display in Winforms using LINQ (C#)" from Code Project

Brian
  • 14,610
  • 7
  • 35
  • 43

1 Answers1

0

I believe that should be a Group Join in VB.NET :

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}

References :

Community
  • 1
  • 1
har07
  • 88,338
  • 12
  • 84
  • 137